DIF - Dynamic Index Facility

DIF moved to GitHub on 2018-21-05. Please use it as new reference site.
See also the new DIF-derived package SID. It does not require MySQL/MariaDB source code and it is usable with any Linux/MacOS installation!
DIF is a set of tools aimed at implementing a powerful indexing system for astronomical catalogs and other data with spherical coordinates, stored into MySQL / MariaDB databases. DIF is able to use both HTM and HEALPix pixelization schemas and it allows very fast query execution even on billion-row tables.

DIF has been developed on the GNU/Linux platform and is released under the GPL license. This site contains all news, updates, documentation and downloadable software packages. The site is still under development, so check for updates.

Installation

See the PDF documentation and GitHub page for more details.
Read how to install MySQL 5.1 from source or to use DIF with multiple MySQL servers (TXT).
Below a typical installation of DIF version 0.5.5 on a Linux / Mac system with a MySQL 5.7 binary installation:
# DIF QUICK START
#

# Ensure DBD::mysql is installed
sudo cpan install DBD::mysql

# or the OS specific command, e.g. on Mac OS using MacPorts:
sudo port install p5-dbd-mysql

# or on Debian/Ubuntu:
sudo apt-get install libdbd-mysql-perl


# Download packages in a temporary directory
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.24.tar.gz
wget http://ross.iasfbo.inaf.it/dif/dif-0.5.5.tar.gz

# Unpack mysql
tar xvzf mysql-5.7.24.tar.gz

# the directory mysql-5.7.24 will be created

# Compile and install DIF:
tar xvzf dif-0.5.5.tar.gz
cd dif-0.5.5
./configure --with-mysql-source=/complete/path/to/mysql-5.7.24
make
sudo make install

# Install DIF database (the mysql root password will be asked)
dif --install

# The latter command installs an example table with all the Messier
# objects.  To display the content of such table use:
mysql> use DIF;
mysql> SELECT * from Messier;

# Install the HTM index on the example table DIF.Messier
dif --index-htm DIF Messier 6 Ra Decl

# Use DIF index to search in a circular region:
SELECT * FROM Messier_htm_6 WHERE DIF_Circle(82, 22, 100);

# Ensure you are using the index prepending `DESCRIBE` to previous query:
mysql> DESCRIBE SELECT * FROM Messier_htm_6 WHERE DIF_Circle(82, 22, 100);
+----+-------------+---------+------------+------+---------------+---------+---------+------------+------+----------+------------------------------------+
| id | select_type | table   | partitions | type | possible_keys | key     | key_len | ref        | rows | filtered | Extra                              |
+----+-------------+---------+------------+------+---------------+---------+---------+------------+------+----------+------------------------------------+
|  1 | SIMPLE      | dif     | NULL       | ALL  | NULL          | NULL    | NULL    | NULL       |    0 |     0.00 | Using where                        |
|  1 | SIMPLE      | Messier | NULL       | ref  | htmID_6       | htmID_6 | 2       | DIF.dif.id |    1 |   100.00 | Using index condition; Using where |
+----+-------------+---------+------------+------+---------------+---------+---------+------------+------+----------+------------------------------------+

Below a typical installation on a Linux / Mac system with a locally compiled MySQL 5.7 source distribution:
# DIF QUICK START
#

# Ensure DBD::mysql is installed
sudo cpan install DBD::mysql

# Download packages in a temporary directory
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.24.tar.gz
wget http://ross.iasfbo.inaf.it/dif/dif-0.5.5.tar.gz

# Compile and install mysql
tar xvzf mysql-5.7.24.tar.gz
cd mysql-5.7.24/
cmake . -DWITH_BOOST=boost
make
sudo make install
sudo groupadd mysql
sudo useradd -r -g mysql -s /bin/false mysql

# Create the file `/etc/my.cnf` with the following content:
[mysqld]
secure-file-priv = ""

# Initialize the server.
# IMPORTANT: Take note of the generated random password!
cd /usr/local/mysql
sudo bin/mysqld --initialize --user=mysql
sudo bin/mysql_ssl_rsa_setup

# Start the server (this command must be executed as root)
/usr/local/mysql/bin/mysqld_safe --user=mysql &

# Connect as root using the random password generated above...
mysql -u root -p

# ... and change it with:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

# Now logout and re-connect with the new password
mysql -u root -p

# Compile and install DIF:
tar xvzf dif-0.5.4.tar.gz
cd dif-0.5.4
./configure --with-mysql-source=/complete/path/to/mysql-5.7.24
make
sudo make install

# Install DIF database (the mysql root password will be asked)
dif --install

# The latter command installs an example table with all the Messier
# objects.  To display the content of such table use:
mysql> use DIF;
mysql> SELECT * from Messier;

# Install the HTM index on the example table DIF.Messier
dif --index-htm DIF Messier 6 Ra Decl

# Use DIF index to search in a circular region:
SELECT * FROM Messier_htm_6 WHERE DIF_Circle(82, 22, 100);

# Ensure you are using the index prepending `DESCRIBE` to previous query:
mysql> DESCRIBE SELECT * FROM Messier_htm_6 WHERE DIF_Circle(82, 22, 100);
+----+-------------+---------+------------+------+---------------+---------+---------+------------+------+----------+------------------------------------+
| id | select_type | table   | partitions | type | possible_keys | key     | key_len | ref        | rows | filtered | Extra                              |
+----+-------------+---------+------------+------+---------------+---------+---------+------------+------+----------+------------------------------------+
|  1 | SIMPLE      | dif     | NULL       | ALL  | NULL          | NULL    | NULL    | NULL       |    0 |     0.00 | Using where                        |
|  1 | SIMPLE      | Messier | NULL       | ref  | htmID_6       | htmID_6 | 2       | DIF.dif.id |    1 |   100.00 | Using index condition; Using where |
+----+-------------+---------+------------+------+---------------+---------+---------+------------+------+----------+------------------------------------+

# Stop the mysql server with:
/usr/local/mysql/bin/mysqladmin -u root -p shutdown

Change log


DIF written by Giorgio Calderone and Luciano Nicastro

Website maintained by Luciano Nicastro