Using one of the indices to make query faster

From: Denis Perchine <dyp(at)perchine(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Using one of the indices to make query faster
Date: 2000-08-03 06:07:02
Message-ID: 00080313195204.22979@dyp.perchine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)perchine(dot)com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Betaille 2000-08-03 06:11:48 Documentation
Previous Message Denis Perchine 2000-08-03 06:03:08 Functional indices with const params.