Miguel,
Yes, it can make a difference and it's not just PostgreSQL that's
affected. I recently did some testing with MySQL. I had a case
where I had an index spanning three fields. I found that it made a
huge difference which field was at the beginning of the index due to
string comparison performance. It was something like value, key,
template. There was an index across these three fields. I found a
significant difference which order these fields were indexed. The
order shown had the best performance. In this case "value" changed
the most out of the three fields since there was a fixed number of
keys, and even smaller number of templates. Take this example index
{ 54321, orderNumber, standardTemplate }. Now if the index contained
template, key, value in that order the index would look something
like "standardTemplateorderNumber54321" So if you have many rows
using the same template and key then it takes a while for the system
to perform a string comparison of the compound index. However if the
value is place first "54321orderNumberstandardTemplate" the string
comparison performance is quite a bit better. This is a contrived
example in the real world the key and template are actually integer
values representing foreign keys to other tables.
I think this depends on how intelligent the SQL parsing engine is.
I'm no database expert on that end of things, but it's my
understanding that some engines do some optimizations based on
available indices and other criteria. Generally speaking conditional
statements would be evaluated in order. If the first part of an AND
evaluates to false the second part is skipped. But, like I said that
may depend on the database engine being used.
Sorry I don't know if EOF generates the WHERE clause in any
particular order, or if it's just random.
On Jul 11, 2007, at 5:29 PM, Miguel Arroz wrote:
Hi!
I'm looking and the generated SQL from an EOAndQualifier, and it
looks like the order of the "anded" stuff is the inverse one I
write on the code. If I write a qualifier like "bananas = %@ and
apples = %@ and oranges = %@", the generated SQL will be the
reverse (t0.oranges = (...) AND t0.apples = (...) AND to.bananas =
(...)".
Is this normal? Is the order random? What's happening here? I'm
asking this, because from what I understand form the PostgreSQL
docs, the order of the stuff in ANDs (and ORs) may have cause a
really big difference in performance when indexes (and multi-
indexes) are envolved.
Yours
Miguel Arroz
Miguel Arroz
http://www.terminalapp.net
http://www.ipragma.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/robertwalker1%
40mac.com
This email sent to [EMAIL PROTECTED]
--
Robert Walker
[EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]