Re: SQL order of operations question
Posted in 1997
>What are the order of operations enforced by the Informix SQL >parser with regards to AND/OR in a WHERE clause It depends on if the order makes any logical difference. For instance, the optimizer treats the "and" clauses as equal and will execute them depending on which will produce the earliest greatest selectivity. That is if the query were: WHERE a > 50 and b = 60 And there is an index on both columns a and columns 6.... If the optimizer determines that by selecting against' b' will probably result in 10 rows while selecting against 'a' results in 50000 rows, then the query plan will select agains column b first. If however, the optimizer is able to determine that the vast majority of the tuples have 'a' less than 50 and the index on column 'b' has a large number of duplicates, then the select will query against column 'a' first. This decision is based on information gathered when "update statistics" is run. Madison Pruet