|
Archives of the TeradataForumMessage Posted: Fri, 18 Feb 2005 @ 09:25:50 GMT
David Hough wrote:
Maybe you sould ask them to specify where it's exactly stated in the ISO document ;-) When i read that SQL:1999 standard (but i have to admit that i hardly understand what they write), i can't see anything about an order of evaluation. And even if there was, it still may be processed differently, as long as the result is the same. But in the mentioned case it's even a difference in result set, and that's definitly not Standard SQL.
At least it's always the same order from left to right when you write joins, but within search conditions within WHERE it's quite strange: Most DBMSes (of course Oracle does it the other way) evaluate from left to right and they do it always the same way. But Teradata uses both and i still don't know exactly when the optimizer chooses left to right vs. right to left. select * from dbc.logonoff where username = 'bla' and logdate = date '2005-02-18'; with a condition of ("(DBC.EventLog.DateFld = DATE '2005-02-18') AND (DBC.EventLog.UserName = 'bla ')") select count(*) from dbc.logonoff where username = 'bla' and logdate = date '2005-02-18'; with a condition of ("(DBC.EventLog.UserName = 'bla ') AND (DBC.EventLog.DateFld = DATE '2005-02-18')") select * from dbc.logonoff where username = 'bla' or logdate = date '2005-02-18'; with a condition of ("(DBC.EventLog.UserName = 'bla ') OR (DBC.EventLog.DateFld = DATE '2005-02-18')") select count(*) from dbc.logonoff where username = 'bla' or logdate = date '2005-02-18'; with a condition of "(DBC.EventLog.UserName = 'bla ') OR (DBC.EventLog.DateFld = DATE '2005-02-18')") If there's a WHERE "mainly false expression" AND "mainly true expression" or WHERE "simple expression" AND "complex expression" it uses much more CPU if it's evaluated in the wrong order, i.e. from right to left. It would be nice, if the optimizer would consider statistics to use the most efficient order. Dieter
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||