Query optimization and indexes

Поиск
Список
Период
Сортировка
От felix@crowfix.com
Тема Query optimization and indexes
Дата
Msg-id 20060818231928.GA19900@crowfix.com
обсуждение исходный текст
Ответы Re: Query optimization and indexes  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Suppose I have an index on 5 columns (A, B, C, D, E).

If my WHERE clause is not in that order, will the optimizer reorder
them as necessary and possible?

    WHERE A=1 AND C=3 AND B=2 AND E=5 AND D=4

Obviously it can't reorder them in all cases:

    WHERE A=1 AND (C=3 OR B=2) AND (E=5 OR D=4)

If I don't specify columns in the WHERE clause, how much can it use
the index?  I think it is smart enough to use beginning columns:

    WHERE A=1 AND B=2

How about skipping leading columns?

    WHERE B=2

How about skipping intermediate columns?

    WHERE A=1 AND C=3

Or both, which is probably the same?

    WHERE B=2 AND D=4?

--
            ... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
     Felix Finch: scarecrow repairman & rocket surgeon / felix@crowfix.com
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: Connection string
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Query optimization and indexes