Is MySQL slow to query for the first time?

problem description

there is a user table with

in it.
uid
regdate //
reg_package //
reg_channel //
...

now I have a SQL query for user data

SELECT * FROM `user` ORDER BY `regdate` DESC  LIMIT 0,50;

there is a multi-column index on this table. idx_regdate_reg_package_reg_channel (key_len has 202)
this SQL also uses this index (using EXPLAIN to see)

question

When

this statement is executed for the first time, the query speed of is very slow , and then it will be much faster. I am very confused here
PS:. I know that InnoDB indexes need buffering. Does it have anything to do with buffering?

The reason why

is slow does not lie in this sentence. If I made a mistake, I checked. It is select COUNT (*) FROM user that the sentence is slow


there are many caches in the database, sql parsing cache, query result cache, index cache, you say slow first, then fast, probably query result cache. You can try to change the parameters in the second query:

as for the first time

SELECT * FROM `user` ORDER BY `regdate` DESC LIMIT 0,50;

second time

SELECT * FROM `user` ORDER BY `regdate` DESC LIMIT 5,55;

see if it's slow, too?


if the amount of data is large, please do not use select *, it is recommended to use select field

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37a18-4ed13.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37a18-4ed13.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?