Обсуждение: Using one of the indices to make query faster

Поиск
Список
Период
Сортировка

Using one of the indices to make query faster

От
Denis Perchine
Дата:
Hello,

Just small question about postgres query optimizer.
If I have a table with 2 fields a and b.
I have indices for both of them.
Table is quite large (> 100000).
I do:

select * from q where a = 10 and b = 20;
I know that the best solution is to build the index on both columns, but...
Will postgres consider to use one of the indices to make initial cut?

This should be quite useful...

One example where this will be useful is:
we have a query where one of the conditions is very restrivtive and
index can be used on it, another condition is complicated functional one.

If we use index on the first column and calculate all others this will be much
faster than sequence scan.

Any thoughts?

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------