The query:
EXPLAIN EXTENDED
SELECT *, u.user_id
FROM xgate_geoloc g
JOIN tig_users u
ON g.uid = u.uid
WHERE
-- corners selection:
( ( (lat BETWEEN COALESCE(?, lat) and COALESCE(?, lat))
AND (lat NOT BETWEEN COALESCE(?, lat) and COALESCE(?, lat))
)
OR ( (lon BETWEEN COALESCE(?, lon) and COALESCE(?, lon))
AND (lon NOT BETWEEN COALESCE(?, lon) and COALESCE(?, lon))
)
)
AND sex = COALESCE(?, sex)
AND language = COALESCE(?, language)
AND city = COALESCE(?, city)
AND province = COALESCE(?, province)
AND country = COALESCE(?, country)
AND time BETWEEN COALESCE(?, time) and COALESCE(?, time)
ORDER BY time DESC
- does that "OR" in the where expression have any effect on te index I should be using ?
- 'time' field is used in both where and order by. Any way to forge an index in this scenario ?
- order by time desc - descending order; yet another bummer
Thanks for the input!
SHOW CREATE TABLE
output for both tables. While at it, the output ofEXPLAIN
would be useful too.