Using one of the indices to make query faster - Mailing list pgsql-general

From Denis Perchine
Subject Using one of the indices to make query faster
Date
Msg-id 00080313195204.22979@dyp.perchine.com
Whole thread Raw
List pgsql-general
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
----------------------------------

pgsql-general by date:

Previous
From: Daniel Betaille
Date:
Subject: Documentation
Next
From: Alessio Bragadini
Date:
Subject: Re: Re: Slash on PostgreSQL mailing list