Re: ADQL v0.7.3

From: Alberto Micol <Alberto.Micol-at-eso.org>
Date: Thu, 04 Mar 2004 19:24:46 +0100

>On Wednesday 3 March 2004 13:49, Ray Plante wrote:
>
>
>>> As I've mentioned, my own reading of the SQL-92 standard suggests that
>>> ANDs and ORs are evaluated left-to-right in the absence of parentheses;
>>> however, I don't feel 100% on this. The alternate interpretation would
>>> be
>>> that its system dependent. Since we are developing ADQL for
>>> cross-database queries, I don't think this latter state is good one to
>>> be
>>> in.
>>
>>
>
>It isn't specified because the db can optimise the query execution by chosing
>the best of several logially equivalent evaluation orders.
>

Thanks Pat,

You made me just realise that there might be a possible source of confusion, (or it was simply my own confusion?) between the SQL precedence and the way things get evaluated by the optimizer.

What is not specified in the standard is how the optimizer will work, not the fact that
there is a well defined precedence of ANDs over ORs etc. That is,

(a and b) or c

is equivalent to

(a or c) and (b or c)

It's the db optimizer that will choose what to do  (even though I guess which one will be picked up in this dummy case:-).

But

a and b or c

is logically equivalent to

(a and b) or c

and not to

a and (b or c)

which is what I thought Ray was originally claiming.

>For services with a
>database in the back-end, we definitely do not want to specify the order.
>

Absolutely.

My apologies,

Alberto Received on 2004-03-04Z19:25:10