auto_index is a PostgreSQL extension that automatically identifies beneficial indexes during query execution and creates them dynamically using background workers.
| File | Description |
|---|---|
auto_index.c |
Core implementation of planner/executor hooks, background worker logic, and index analysis. |
auto_index.h |
Header file declaring functions, hooks, and required PostgreSQL includes. |
auto_index.control |
Extension control file with metadata for PostgreSQL. |
auto_index--1.0.sql |
SQL script to set up the extension and required database objects. |
Makefile |
Build configuration for compiling the extension with PGXS. |
run_query.py |
Spawns threads and runs queries from each of the threads. Helpful for running queries large number of times. |
The following steps describe how to integrate the auto_index extension into your PostgreSQL installation.
-
Adding the Extension
- Copy the
auto_indexfolder into thecontribdirectory of your PostgreSQL source tree. - Add
auto_indexto theshared_preload_librariessetting in thepostgresql.conffile of your database:shared_preload_libraries = 'auto_index'
- Copy the
-
Compilation and Installation
- Open a terminal and navigate to the
auto_indexdirectory. - Run the following commands:
make sudo make install
- Open a terminal and navigate to the
-
Initialize the Extension
- To initialize the extension (e.g., every time you start using it), connect to your database and run:
CREATE EXTENSION auto_index;
- This sets up the required
aidx_queriestable used to track indexing opportunities.
- To initialize the extension (e.g., every time you start using it), connect to your database and run:
-
Cleanup
- To remove the extension and clean up allocated resources, run:
DROP EXTENSION auto_index;
- This will remove the
aidx_queriestable and deactivate the extension.
- To remove the extension and clean up allocated resources, run: