View Single Post

   
  #2 (permalink)  
Old 05-16-2008, 01:39 PM
Dan Guzman
 
Posts: n/a
Default Re: a and (b or c) better than (a and b) or (a and c) ?

> Is it only because it is easier to display the query in the query-design
> table?


Yes, I believe EM changes the query to facilitate GUI display.

> Or is it actually a more efficient method?


SQL is declarative rather than procedural. The optimizer in the database
engine will try to generate the most efficient plan regardless of how the
query is expressed. If you compare the execution plans of the 2 queries in
Query Analyzer, I would expect both to be identical because they are
semantically identical.

--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

"Leif Neland" <leif@neland.dk> wrote in message
news:482c078c$0$15887$edfadb0f@dtext01.news.tele.d k...
> When I use "sql server enterprise manager" gui and write an expression
> like
>
> where a=1 and (b=2 or c=3)
>
> it gets transformed into
>
> where (a=1 and b=2)
> or (a=1 and c=3)
>
> Is it only because it is easier to display the query in the query-design
> table?
>
> Or is it actually a more efficient method?
>
> I.e, when I take the finished query and paste it into my asp-source,
> should I keep the transformed query, which is larger, or transform it back
> to the way I originally wrote it?
>
> Leif


Reply With Quote