Re: Trying to work out why a join query is so slow

2009-02-02 Thread Baron Schwartz
This is going to return duplicate rows if there are results that match both conditions. One of the queries needs a condition to exclude the results that'll be sent in the other query. You can do it this way, and in some cases it's faster. But, what I think we should really be asking is: 1) what

RE: Trying to work out why a join query is so slow

2009-02-01 Thread Martin Gainty
endorse content contained within this transmission. > Date: Sun, 1 Feb 2009 17:23:10 -0500 > Subject: Re: Trying to work out why a join query is so slow > From: ysn...@gmail.com > To: si...@internetstuff.ltd.uk > CC: mysql@lists.mysql.com > > My guess is that the OR i

Re: Trying to work out why a join query is so slow

2009-02-01 Thread Sangeetha
My guess is that the OR is searching the whole table for each element of the other table. It compounds the select statement. You may try a Union.Im new to Mysql so im not sure it will work, but you might try it out. SELECT * FROM sites INNER JOIN users ON sites.userid = users.ID WHERE sites.email

Trying to work out why a join query is so slow

2009-02-01 Thread Simon Kimber
Hi Everyone, I'm trying to run a very simple query on two joined tables but it's taking a long time to run. I have two tables, users and sites, both of which have an email address field that I'm querying. here's my query: SELECT * FROM sites INNER JOIN users ON sites.userid = users.ID