Am I blind, or are those two queries the same?

James Pharaoh wrote:

Hi,

I'm trying to optimize the following query:

SELECT *
FROM user LEFT JOIN history ON user.userid = history.touserid OR
user.userid = history.fromuserid
WHERE user.state = 'ready'
GROUP BY user.userid

This causes a full table scan on the second table. If I do the following
however the index is used:

SELECT *
FROM user LEFT JOIN history ON user.userid = history.touserid OR
user.userid = history.fromuserid
WHERE user.state = 'ready'
GROUP BY user.userid

The full table scan is causing my app to slow down as the history gets
larger, and it's really more convenient for me to link the tables this
way.

I'm using myql 3.23.49.

Anyone have any ideas?

James
[EMAIL PROTECTED]


---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php





---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to