Hey, I was recently doing my routine check of the slow query log and decided to try optimise some of the queries. One of them is like so: SELECT name FROM entries WHERE type = '5' ORDER BY id DESC LIMIT 30 Type is an index, id is a primary key. This query took 5 seconds according to the slow log (but a lot of that time was probably caused by other things slowing mysql at the same time). But yeah, my question is, how would I speed up such a query? The table has 10k rows so isn't that big yet. MySQL automatically ignores the type key as the cardinality is too low. This is why it shows in the slow log as it appears to not make use of indexes. Also, related to the same problem I have a query like so: SELECT id,title,description,content,type FROM news WHERE title LIKE '%test%' ORDER BY id DESC LIMIT 0,30 On this query, ID is primary, type and title are indexes. Type is yet again too low a cardinality to be used. This query is the slowest on my server and I'm out of ideas of how to speed it up. So yeah any help would be appreciated.
Ah I tried fulltext and it works great. The query is executed MUCH faster. I did consider it before but was told it wouldn't help, good thing I tried it