Andrew Rawnsley <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to