The speed of php reading mysql is a database with about 10 thousand records.
Select id, old_id, iid, title1, page_type from mayi_news where page_type = 'test'
The speed is 32 milliseconds.
Select id, old_id, iid, title1, page_type from mayi_news where page_type = 'test' order by id desc
The speed is 480 milliseconds.
Why are there so many differences?
Another question is: I recently checked that the moderator provided the EXPLAIN test performance. I don't know how to optimize the following results?
Reply to discussion (solution)
Extra columns have filesort
Indicates that temporary files are used as the carrier of the index tree during sorting, which obviously causes a speed decrease.
Observe that the possible_keys and Key columns are empty, indicating that no index is used.
Therefore, you can create an index on id and page_type and observe the effect.
Is id a primary key? why is there such a big difference in sorting by primary key?