SELECT *
From add
ORDER by LENGTH (title) DESC
LIMIT 10
Data 20W, execute more than 1 seconds .... How to optimize WOW
Reply to discussion (solution)
It's the simplest of all. It is recommended to use the cache bar query results cached without the need to repeatedly query
I'm afraid the order by will not be able to optimize, 1 seconds more not slow ah.
20W not much, it is recommended to redesign the database, create a new column, save length (title), when inserted, with strlen ($title) calculation. The new column is then indexed. (If the ID is self-increasing, you can try to use the ID and the new column as a primary key)
In addition, do not use SELECT *, with select Title,content,date and the like, the column you need to write out.
Make an index of LENGTH (title)
Your sort of rules are weird, yo.
Desc SELECT *
From add
ORDER by LENGTH (title) DESC
LIMIT 10
Parse the next SQL, key field plus index.
Keywords plus indexing can improve efficiency.
can select * Do not return all fields? You can store more than one field to hold the value of LENGTH (title), and maintain this value (update and insert) with two triggers, and then build the index on this column, it should be better.