chaoswar4u Posted January 18, 2009 Posted January 18, 2009 Im trying to work out methods of improving query loads on my server. Please take a look at the following query as an example. $is=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid"); Now queries that start with such things as SELECT u.*,us.* FROM dont sink in the old brain too well as of yet. I was wondering if this query is fully optimized or is there a better way. Any insight would be great to better understand queries of this nature. Quote
a_bertrand Posted January 18, 2009 Posted January 18, 2009 Re: Query. Optimized? There is also a good free way to know how optimized your queries are, and if you need either to change your queries or add indexes to your tables: Simply open your trusted phpMyAdmin and run your query (works only with select queries!) adding the keyword EXPLAIN: EXPLAIN SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=1 That will give you back the info of how many rows have been loaded to get your data back and more... Always a very useful tool. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.