Hey all,
I would like to know why when having big data in mysql table, executing a query for the first time takes 0.1.. sec, but if executing again the same query later, it will take only 0.0006 sec ?
SELECT name FROM users where id > 310000 limit 20
takes: 0.1844 sec the first time executed
and it takes: 0.0006 sec when excecuted again

Is there caching or data management ?
The speed will stay permanently ~0.0006 after executing it for the first time ?

Thank you :)

Yes, there are different caches, check the documentation for more information:

And there are some limitations, as the subqueries cannot be cached:

But if you use MariaDB, which is a fork of MySQL, you can cache even those queries:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.