SELECT * FROM users LEFT JOIN (SELECT * FROM userHits) tx1 ON tx1.id=(SELECT id FROM userHits USE INDEX(userId) WHERE userId=users.id ORDER BY id DESC LIMIT 1);
0.91 seconds
SELECT * FROM users LEFT JOIN (SELECT * FROM userHits) tx1 ON tx1.id=(SELECT id FROM userHits WHERE userId=users.id ORDER BY id DESC LIMIT 1);
~15 seconds
**I realize the cardinality is low (its at 2), which is why MySQL isn't using it, but if a cardinality of 2 speeds up a query by 15x it seems sensible that it should use all indexes even if the cardinality is low. **
Can I configure this in my.cnf to force all indexes be used? Is there a way around this besides specifying the index in the query?
These are all innodb tables, so I thought it best to be in this forum. Excuse me if I was wrong.
Thanks!
0.91 seconds
SELECT * FROM users LEFT JOIN (SELECT * FROM userHits) tx1 ON tx1.id=(SELECT id FROM userHits WHERE userId=users.id ORDER BY id DESC LIMIT 1);
~15 seconds
**I realize the cardinality is low (its at 2), which is why MySQL isn't using it, but if a cardinality of 2 speeds up a query by 15x it seems sensible that it should use all indexes even if the cardinality is low. **
Can I configure this in my.cnf to force all indexes be used? Is there a way around this besides specifying the index in the query?
These are all innodb tables, so I thought it best to be in this forum. Excuse me if I was wrong.
Thanks!