Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Statement Speed

Status
Not open for further replies.

sflau

Programmer
Oct 18, 2001
87
0
0
HK
I am using SQL 7. And have questions for the speed of the following SQL statement:

1. Comparing
"Select * from TableA Inner join TableB
on TableA.Field1 = TableB.Field2"
Vs
"Select * from TableA, TableB
Where TableA.Field1 = TableB.Field2"

Which is faster?

2. Comparing
TableA is large size (> 10000 records)
TableB is smaller size (< 500 records)

&quot;Select * from TableA Inner join TableB
on TableA.Field1 = TableB.Field2&quot;

&quot;Select * from TableB Inner join TableA
on TableA.Field1 = TableB.Field2&quot;

Which is faster?

Please help, thank you.
 
I would always use &quot;Select * from TableA Inner join TableB
on TableA.Field1 = TableB.Field2&quot;. Must admit I dont know if swapping the order would make any difference but doubt it. Other views ?

For speed ensure you have indexes on TableA.field1 and TableB.Field2. Plus put the query in a stored procedure.
 
1. Both statements will produce exactly the same execution plan (and perform the same) as they are functionally equivalent. They only differ syntactically.

2.The order you specify the tables doesn't matter at all. Both will perform exactly the same also.

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top