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)

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

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

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

2009-02-01 Thread Martin Gainty
UNION all does a cartesian join ..maxiumum number of results will be delivered SELECT * FROM sites INNER JOIN sites.userid = users.ID; -- INNER JOIN users ON sites.userid = users.ID --ALSO put (hopefully UNIQUE indexes) on sites.userid and users.id Martin