Jump to content
MakeWebGames

Recommended Posts

Posted

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.

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...