Gossamer Forum
Home : General : Databases and SQL :

query speed

Quote Reply
query speed
which one result the fast query speed?



SELECT * FROM Artist,CD WHERE (CD.ArtistID=Artist.ArtistID) AND Artist.ArtistID=22;



SELECT * FROM (Artist INNER JOIN CD ON CD.ArtistID=Artist.ArtistID) WHERE Artist.ArtistID=22;



Thanks
Quote Reply
Re: [courierb] query speed In reply to
Benchmark them :)

....if you execute the queries from ssh/telnet mysql tells you x rows affected in x seconds.
Quote Reply
Re: [courierb] query speed In reply to
Depending on the number of rows you have in the table, using the WHERE clause for PK_FK connections is nominally slower than using JOINS. If you have tons of rows/records, like above 100,000, it is better to use JOINS.

However, good habit in SQL coding is to use the most efficient set of codes as possible.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [courierb] query speed In reply to
They are identical on mysql. From mysql.com:

Quote:
INNER JOIN and , (comma) are semantically equivalent. Both do a full join between the tables used. Normally, you specify how the tables should be linked in the WHERE condition.


Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] query speed In reply to
That's good to know. I've been using the first example (comma deliminated) mosty because of it's clarity when reading my code.

- wil
Quote Reply
Re: [Wil] query speed In reply to
Its also easier when writing your own SQL module :)
Quote Reply
Re: [Paul] query speed In reply to
Yeah. I can see your point. Just line 'em up seperated by commas and job done :-)

- wil
Quote Reply
Re: [Wil] query speed In reply to
Thank you all .



Yes, a Benchmark test will tells all.