[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> on Monday, August 25, 2003 9:59 AM said:
> At the moment, all queries on the website follow the same format when > joining tables: > SELECT * FROM table1,table2 WHERE table1.id=table2.id; > > My question is, would this format be more efficient? > SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id; I know this isn't really the answer you were looking for but the best way to determine this is to create a test page using the product sql queries and time them. Put them in a loop of maybe 100 iterations and see how long it takes to execute the two different queries. Start Timer For(100 times) { Execute my original query } Stop Timer echo Stop Timer minus Start Timer Start Timer For(100 times) { Execute my new query } echo Stop Timer minus Start Timer That will give you some good info. Also I've been told that you should never use SELECT *. I've been told that this causes extra overhead on the db because it has to first query the table to figure out what columns are in the table and THEN select them. It's faster to list all the fields, even if you want to select all of them. In fact it might be worth your while to try four different tests. 1. Original Query 2. New Query 3. Original Query with Fields Listed 4. New Query with Fields Listed Let us know what happens. Chris. p.s. In case you don't know, look into the microtime() function for examples of how to time your scripts. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php