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 tab
Maybe I'm missing something, but those queries look the same to me.
I think it's your use of OR that is causing things to slow down. Try
using a table alias and another left join instead and see if that speeds
things up.
SELECT *
FROM user LEFT JOIN history ON user.userid=history.touserid
LEFT
Are indexes present on both tables? Do the columns that are being joined
upon both indexed?
-Original Message-
From: James Pharaoh [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 05, 2003 11:28 AM
To: [EMAIL PROTECTED]
Subject: 1 column - 2 column join optimisation
Hi,
I'm t
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