Re: If an index is based on 3 columns will a query using two of the columns utilize the index?

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: If an index is based on 3 columns will a query using two of the columns utilize the index?
Дата
Msg-id 20050912140041.GB7856@surnet.cl
обсуждение исходный текст
Ответ на If an index is based on 3 columns will a query using two of the columns utilize the index?  ("Reid Thompson" <Reid.Thompson@ateb.com>)
Ответы Re: If an index is based on 3 columns will a query using two of the columns utilize the index?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Mon, Sep 12, 2005 at 09:43:57AM -0400, Reid Thompson wrote:
> Example:
> assume a table of 10 columns, three of which are fname, lname, and dob.
> If an index is created on (fname, lname, dob), will a query that
> utilizes two of the columns ( select 'data' from table where fname = 'X'
> and lname = 'Y') utilize the index?

Yes, if it is selective enough.  (It _can_ use the index, which does not
mean that it _will_ use it.)  Note that if your example query used the
columns (lname, dob), the answer would be "no."

--
Alvaro Herrera -- Valdivia, Chile         Architect, www.EnterpriseDB.com
Officer Krupke, what are we to do?
Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke")

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

Предыдущее
От: "Reid Thompson"
Дата:
Сообщение: If an index is based on 3 columns will a query using two of the columns utilize the index?
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: If an index is based on 3 columns will a query using two of the columns utilize the index?