WHERE order

Started by Rod Taylorover 22 years ago2 messageshackers
Jump to latest
#1Rod Taylor
rbt@rbt.ca

It would appear that in 7.4 the order of clauses in WHERE affects the
execution time (not output if AND).

I would think that a simple optimization would be to push off evaluation
of a subplan whenever possible by re-arranging AND statements.

In the below example, it gives an order of magnitude speed increase on a
small dataset.

Attachments:

long.querytext/plain; charset=ISO-8859-1; name=long.queryDownload
long.explaintext/plain; charset=ISO-8859-1Download
short.explaintext/plain; charset=ISO-8859-1Download
short.querytext/plain; charset=ISO-8859-1; name=short.queryDownload
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rod Taylor (#1)
Re: WHERE order

Rod Taylor <rbt@rbt.ca> writes:

I would think that a simple optimization would be to push off evaluation
of a subplan whenever possible by re-arranging AND statements.

Thought we did that already ... [ checks code ] ... hmph, it looks like
this is done correctly for quals attached to a scan node, but not for
quals attached to a join node. Oops.

regards, tom lane