473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Use ANSI Join or Old Style Join?

Hi,

Just curious. Would you use ANSI style table joining or the 'old
fashion' table joining; especially if performance is the main concern?

What I meant is illustrated below:

ANSI Style
select * from a join b on a.id = b.id

Old Style
select * from a, b where a.id = b.id

I noticed that in some SQL, the ANSI is much faster but sometimes, the
old style looks much better.

It's ridiculous to try out both styles to see which is better whenever
we want to write an SQL statement.

Please comment.

Thanks in advance.

May 20 '06 #1
1 10953
ehchn1 wrote:
Hi,

Just curious. Would you use ANSI style table joining or the 'old
fashion' table joining; especially if performance is the main concern?

What I meant is illustrated below:

ANSI Style
select * from a join b on a.id = b.id

Old Style
select * from a, b where a.id = b.id

I noticed that in some SQL, the ANSI is much faster but sometimes, the
old style looks much better.

It's ridiculous to try out both styles to see which is better whenever
we want to write an SQL statement.

Please comment.

Thanks in advance.


I'm interested if you have an example where two otherwise identical
inner joins will yield different execution plans with a resulting
difference in performance. Usually they give equivalent plans whether
you specify the join as INNER JOIN or in the WHERE clause. This is
definitely not true for outer joins however. Always use the OUTER JOIN
syntax instead of the *= notation.

I am aware of two very unusual circumstances where you can get
different results from the INNER JOIN syntax. One is a bug in SQL
Server 2000, the other is with the GROUP BY ALL feature (rarely used in
my experience).

It is incorrect to describe your two queries as ANSI versus "Old
Style". Both are compliant with the ANSI standards SQL92, SQL99 AND
SQL2003. Whether and when to specify join conditions using the INNER
JOIN syntax or not is largely a matter of style and clarity. The
convention I normally use is that if the criteria used for the join is
a foreign key between the two tables then I specify it using in the ON
clause, which therefore requires an INNER JOIN. Otherwise I specfy it
in the WHERE clause, which may mean I can leave out the INNER JOIN. I
don't always follow my own rules though :-)

If an OUTER JOIN is involved as well then it's no longer just a matter
of style. Specifying the same criteria in the WHERE clause versus the
ON clause makes a difference to the meaning of the query if it
references the outer part of an outer join. Maybe that explains what
you are referring to as a performance difference. Can you give a fuller
example? Make sure you specify your SQL Server version and service
pack.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--

May 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ColdCanuck | last post by:
Help! I'm trying to understand the new ANSI join syntax (after many years of coding using the old style). I am now working with an application that only understands ANSI syntax so I am...
3
by: jakelake | last post by:
Help....I have a DB I'm working with that I know doesn't work with the ANSI-92 JOIN SYNTAX....I'm not sure how much this limits my ability to deal with the following situation, so I'm soliciting...
5
by: RK | last post by:
I need to compile a library of C code with pre-ANSI C functions using MS ..NET 2003. The functions are declared something like this: int myFunction(p) double p; { int x; code here... return...
2
by: Martín Marconcini | last post by:
Hello there, I'm writting (or trying to) a Console Application in C#. I has to be console. I remember back in the old days of Cobol (Unisys), Clipper and even Basic, I used to use a program...
4
by: Kza | last post by:
Hi, just in the process of maintaining some software that used some funy old string library and char*s , and we are updating everything to use std::strings. (or should I say std::basic_string<>s) ...
15
by: Bart Vandewoestyne | last post by:
I'm having a .c source file which at the top contains the line #include <math.h> In that source file, i declare a function dt which in its body uses the lgamma function. `man lgamma' on my...
83
by: sunny | last post by:
Hi All What is C99 Standard is all about. is it portable, i mean i saw -std=C99 option in GCC but there is no such thing in VC++.? which one is better ANSI C / C99? can i know the major...
10
by: Michael B. Trausch | last post by:
Alright... I am attempting to find a way to parse ANSI text from a telnet application. However, I am experiencing a bit of trouble. What I want to do is have all ANSI sequences _removed_ from...
6
by: dunleav1 | last post by:
I have an application that uses the old join syntax instead of the SQL92 standards join syntax. I need to justify changing the code to the new standard. Is there any performance issue related to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.