Re: 1 column - 2 column join optimisation

2003-02-07 Thread gerald_clark
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

Re: 1 column - 2 column join optimisation

2003-02-07 Thread Brent Baisley
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

RE: 1 column - 2 column join optimisation

2003-02-07 Thread Victor Pendleton
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

1 column - 2 column join optimisation

2003-02-06 Thread James Pharaoh
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