Deciding which index to use

Started by Christophe Pettusabout 11 years ago2 messages
#1Christophe Pettus
xof@thebuild.com

Where in the optimizer code does PostgreSQL decide which of several possibly-matching partial indexes to use?
--
-- Christophe Pettus
xof@thebuild.com

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christophe Pettus (#1)
Re: Deciding which index to use

Christophe Pettus <xof@thebuild.com> writes:

Where in the optimizer code does PostgreSQL decide which of several possibly-matching partial indexes to use?

It costs them all out and uses the cheapest.

If the cost estimates come out exactly the same, you get an arbitrary
choice (I think probably always the index with smallest OID, but that's
an implementation artifact rather than something that's done explicitly
anywhere).

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers