support for 9.1
[plantuner.git] / README.plantuner
1 Plantuner - enable planner hints
2
3    contrib/plantuner is a contribution module for PostgreSQL 8.4+, which
4    enable planner hints.
5
6    All work was done by Teodor Sigaev (teodor@sigaev.ru) and Oleg Bartunov
7    (oleg@sai.msu.su).
8
9    Sponsor: Nomao project (http://www.nomao.com)
10
11 Motivation
12
13    Whether somebody think it's bad or not, but sometime it's very
14    interesting to be able to control planner (provide hints, which tells
15    optimizer to ignore its algorithm in part), which is currently
16    impossible in POstgreSQL. Oracle, for example, has over 120 hints, SQL
17    Server also provides hints.
18
19    This first version of plantuner provides a possibility to hide
20    specified indexes from PostgreSQL planner, so it will not use them.
21
22    There are many situation, when developer want to temporarily disable
23    specific index(es), without dropping them, or to instruct planner to
24    use specific index.
25
26 Installation
27
28      * Get latest source of plantuner from CVS Repository
29      * gmake && gmake install && gmake installcheck
30
31 Usage
32
33    To enable the module you can either load shared library 'plantuner' in
34    psql session or specify 'shared_preload_libraries' option in
35    postgresql.conf.
36 =# LOAD 'plantuner';
37 =# create table test(id int);
38 =# create index id_idx on test(id);
39 =# create index id_idx2 on test(id);
40 =# \d test
41      Table "public.test"
42  Column |  Type   | Modifiers
43 --------+---------+-----------
44  id     | integer |
45 Indexes:
46     "id_idx" btree (id)
47     "id_idx2" btree (id)
48 =# explain select id from test where id=1;
49                               QUERY PLAN
50 -----------------------------------------------------------------------
51  Bitmap Heap Scan on test  (cost=4.34..15.03 rows=12 width=4)
52    Recheck Cond: (id = 1)
53    ->  Bitmap Index Scan on id_idx2  (cost=0.00..4.34 rows=12 width=0)
54          Index Cond: (id = 1)
55 (4 rows)
56 =# set enable_seqscan=off;
57 =# set plantuner.forbid_index='id_idx2';
58 =# explain select id from test where id=1;
59                               QUERY PLAN
60 ----------------------------------------------------------------------
61  Bitmap Heap Scan on test  (cost=4.34..15.03 rows=12 width=4)
62    Recheck Cond: (id = 1)
63    ->  Bitmap Index Scan on id_idx  (cost=0.00..4.34 rows=12 width=0)
64          Index Cond: (id = 1)
65 (4 rows)
66 =# set plantuner.forbid_index='id_idx2,id_idx';
67 =# explain select id from test where id=1;
68                                QUERY PLAN
69 -------------------------------------------------------------------------
70  Seq Scan on test  (cost=10000000000.00..10000000040.00 rows=12 width=4)
71    Filter: (id = 1)
72 (2 rows)