Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL: where vs. join
Message
 
 
To
10/08/2009 16:13:14
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01416873
Message ID:
01417190
Views:
46
>>>>>>Hi Naomi,
>>>>>>>There should not be difference in performance, IMHO, but I would always prefer JOIN syntax over WHERE syntax for better readability.
>>>>>>>
>>>>>>>Also JOIN and WHERE behave differently, JOIN happens first, then WHERE.
>>>>>>
>>>>>>Nope. Filtering normally comes first to speed up by reducing set size (usually the where clause) and then the join-operation.
>>>>>>If there is a filter in the join condition SOMETIMES this is also executed during the first step (depends on the smarts of the engine).
>>>>>>
>>>>>>regards
>>>>>>thomas
>>>>>
>>>>>I'm not sure this is correct (I believe it's incorrect). See message #1401825
>>>>>
>>>>>There needs to be done a bit of research on the topic to confirm/deny your statement, but I'm busy at the moment - will do the actual research later.
>>>>
>>>>No Join Clause mentioned in there... ;-)
>>>>From needs to be checked first to establish the relevant tables.
>>>>Unless you are talkink about special cases where the join involvels a tables with only a dozen records...
>>>>
>>>>regards
>>>>
>>>>thomas
>>>
>>>I remembered this message #1042994 thus I thought since then that JOIN happens first.
>>
>>It might in Joins involving only a handful of records, which is an eficient filter in itself, but the (for my queries at least) standard way of optimizing is reducing set size via index.
>
>I believe this is correct:
>
>http://www.sql.co.il/books/insidetsql2008/Logical%20Query%20Processing%20Poster.pdf

I was kind of fixated on performance so figured Where would be processed before Join. That chart shows it is not, at least in SQL Server. It probably has to be that way, though, since the Where clause might refer to fields in more than one table. Thanks for posting the chart. (I have the book, BTW, but obviously have not committed it to memory!)
Previous
Reply
Map
View

Click here to load this message in the networking platform