Jump to content
MakeWebGames

Recommended Posts

Posted

Hey everyone,

I recently enabled slow query logging so i can pinpoint troublesome queries..

I seem to have some select queries from the HOF script that are examining like 17mill rows for some reason...

I have reviewed the query but cant figure out why it would be doing this...I even changed the query around a bit...

here is the query:

SELECT u.userid,us.strength FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid!=1 AND u.laston>0 ORDER BY us.strength DESC,u.userid ASC LIMIT 50;

 

I dont understand why its examining a huge amount of non-existence rows...

anyone else had a similar problem ?

Posted

It examines tons of rows when: you don't have indexes or mysql can't use them. Try the "explain" function with the query and you shall see how MySQL work under to execute the query. BTW the "non-existent" rows are basically the cross product of 2 tables:

Table A you have:

a, b, c

Table B you have:

1, 2, 3

The cross product is:

a1, a2, a3, b1, b2, b3, c1, c2, c3

As you see there is a lot more rows in the cross product that in the 2 other tables ;)

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...