Hi,
i'm querying a database like this:
SELECT * from Log WHERE cookieId IN (select cookieId from Log WHERE someId="blafasel");
I have keys on someId and cookieId but yet the query is very slow. If I run the two queries (the outer and the inner) separated both of them or very fast.
select cookieId from Log WHERE someId="blafasel"
gets me the results almost instant. And so does a query
SELECT * FROM Log WHERE cookieId IN ("something","somethingelse","athirdoption")
Using EXPLAIN tells me that keys are used in the two single queries but for the subselect query keys are only used for the inner select. My Question is why? And how to tell MySQL to be a little bit more clever.
Well I could let my application run the two queries separated but that wouldnt be convenient.
Thanks for your help.