same field in bothe "where" and "order by" - how to index for this query? 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!
The OR will most likely affect the index usage, because it hinders index seeking. Generally speaking "OR" is 'bad' for index usage in where clauses.

The time field, it would be sensible to have it in an index sorted in the DESC order when you use it DESC;

Other than that - we'll need more information to give more exact/concrete advice