Re: cannot use multicolumn index

From: Vitalii Tymchyshyn <tivv00(at)gmail(dot)com>
To: MirrorX <mirrorx(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: cannot use multicolumn index
Date: 2011-09-14 15:28:38
Message-ID: 4E70C826.1050800@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

14.09.11 18:14, MirrorX написав(ла):
> i think in my first post i provided most of these details but ->
> 1) what i expect is to be able to understand why the index is not used and
> if possibly to use it somehow, or recreate it in a better way
> 2) the table has 115 GB and about 700 milion rows
> 3) the result should be less than 10 millions rows
> 4) the index is a btree
>
> i tried to disable seq_scan and the query plan was changed and used another
> index and not the one i wanted.
You has ">" check on both columns, this means that it has to scan each
subtree that satisfy one criteria to check against the other. Here index
column order is significant. E.g. if you have a lot of xid > 100 and xid
is first index column, it must check all (a lot) the index subtrees for
xid>100.
Multicolumn indexes work best when first columns are checked with "="
and only last column with range criteria.
You may still try to change order of columns in your index if this will
give best selectivity on first column.
Another option is multiple single column indexes - postgres may merge
such an indexes at runtime (don't remember since which version this
feature is available).

Best regards, Vitalii Tymchyshyn.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tomas Vondra 2011-09-14 16:05:23 Re: cannot use multicolumn index
Previous Message MirrorX 2011-09-14 15:14:00 Re: cannot use multicolumn index