pg_idx_advisor

This Release
pg_idx_advisor 0.1.2
Date
Status
Stable
Latest Testing
pg_idx_advisor 0.1.0 —
Other Releases
Abstract
Index advice for PostgreSQL
Description
pg_idx_advisor is a PostgreSQL extension that gives index tuning recommendations for queries.
Released By
cohenjo
License
PostgreSQL
Resources
Special Files
Tags

Extensions

idx_adv 0.1.2
Index advice for PostgreSQL

Documentation

pg_idx_advisor
pg_idx_advisor 0.1.2

README

# pg_idx_advisor

PGXN version

A PostgreSQL extension to analyze queries and give indexing advise.

Introduction

The index advisor uses the virtual index framework/support built into PG to provide a list of "candidates" for the query engine to choose from.

The following features are enabled/supported (more to come :) ) Feature list: - Partial indexes - CTE - functional indexes - text_pattern_ops - inheritance tables - composite indexes

Installation

make
make install

If you encounter an error such as:

make: pg_config: Command not found

Be sure that you have pg_config installed and in your path. If you used a package management system such as RPM to install PostgreSQL, be sure that the -devel package is also installed. If necessary tell the build process where to find it:

env PG_CONFIG=/path/to/pg_config make && make installcheck && make install

Usage

First you must load the library using the 'LOAD' command: Load '$pglibdir/pg_idx_advisor.so' simply run the query with the "explain" - you will see both the original execution plan as well as the new plan with the suggested Virtual/Hypothetical indexes.

Examples:

``` postgres=# explain select c21 from entities_113681518 where c11 = 200; INFO: * Plan with original indexes *

QUERY PLAN

Seq Scan on entities_113681518 (cost=0.00..10.00 rows=1 width=8) Filter: (c11 = 200)

* Plan with hypothetical indexes * read only, advice, index: create index on entities_113681518(c11) Index Scan using

Works with CTE as well:

``` postgres=# explain with vals as (select c21 from entities_113681518 where c11 = 200 ) select * from vals; INFO: * Plan with original indexes *

QUERY PLAN

CTE Scan on vals (cost=10.00..10.02 rows=1 width=8) CTE vals -> Seq Scan on entities_113681518 (cost=0.00..10.00 rows=1 width=8) Filter: (c11 = 200)

* Plan with hypothetical indexes * read only, advice, index: create index on entities_113681518(c11) CTE Scan on vals (cost=8.02..8.04 rows=1 width=8) CTE vals -> Index Scan using

```

Dependencies

The pg_idx_advisor extension has no dependencies other than PostgreSQL.

Copyright and License

Copyright (c) 2010-2014 Jony Vesterman Cohen.

This module is free software; you can redistribute it and/or modify it under the PostgreSQL License.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.

In no event shall Jony Vesterman Cohen be liable to any party for direct, indirect, special, incidental, or consequential damages, including lost profits, arising out of the use of this software and its documentation, even if Jony Vesterman Cohen has been advised of the possibility of such damage.

Jony Vesterman Cohen specifically disclaim any warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The software provided hereunder is on an "as is" basis, and Jony Vesterman Cohen have no obligations to provide maintenance, support, updates, enhancements, or modifications.