Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Table select statement performance Expand / Collapse
Author
Message
Posted Sunday, January 15, 2012 10:48 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, November 25, 2014 9:35 PM
Points: 89, Visits: 221
Dear Friends,

I am having two tables TB_PERSON_P and TB_PERSON_R
both having a common column R_ID
now we can write two query:

select R_ID from TB_PERSON_P P,TB_PERSON_R R where P.R_ID=R.R_ID

and

Select R_ID from TB_PERSON_P P join TB_PERSON_R on P.R_ID=R.R_ID

which would be faster among these two statement?

Thanks!!
Post #1236386
Posted Monday, January 16, 2012 1:48 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, February 22, 2013 7:38 AM
Points: 283, Visits: 226
They will perform the same (same execution plan), the only difference is one uses the ANSI syntax and the other the old style SQL Server / Sybase syntax.


Robert Murphy, Microsoft MCITP (Database Administrator 2008) and MCAD Certified
Post #1236434
Posted Monday, January 16, 2012 1:52 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, February 22, 2013 7:38 AM
Points: 283, Visits: 226
...and I would recommend specifying the join type for readability if using the improved ANSI joins:

INNER JOIN (default)
RIGHT OUTER JOIN
LEFT OUTER JOIN etc etc



Robert Murphy, Microsoft MCITP (Database Administrator 2008) and MCAD Certified
Post #1236436
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse