Re: faster SELECT

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: faster SELECT
Дата
Msg-id 3872.1078759419@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: faster SELECT  (Andrew Rawnsley <ronz@ravensfield.com>)
Список pgsql-general
Andrew Rawnsley <ronz@ravensfield.com> writes:
> It is a fairly well known optimization in Oracle (at least with the
> rule-based optimizer, and IIRC non-indexed clauses) to optimize the
> WHERE clause right to left.

That rule doesn't apply to Postgres, though.

If the optimizer does not have any reasons of its own to reorganize the
query (and that's a pretty big "if") then the WHERE clauses will get
evaluated left-to-right.  So if you know which clause is more selective,
write it first.

In practice this really only applies to restriction clauses
(single-relation tests) that are not going to be implemented via an
index scan.  Join and index clauses will get sliced, diced, and used
no matter what order you list 'em in.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: postmaster freeze
Следующее
От: "Markus Wollny"
Дата:
Сообщение: Character Encoding Confusion