Re: cannot use multicolumn index

Поиск
Список
Период
Сортировка
От Vitalii Tymchyshyn
Тема Re: cannot use multicolumn index
Дата
Msg-id 4E70C826.1050800@gmail.com
обсуждение исходный текст
Ответ на Re: cannot use multicolumn index  (MirrorX <mirrorx@gmail.com>)
Список 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.


В списке pgsql-performance по дате отправления:

Предыдущее
От: MirrorX
Дата:
Сообщение: Re: cannot use multicolumn index
Следующее
От: "Tomas Vondra"
Дата:
Сообщение: Re: cannot use multicolumn index