Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will UNIX_TIMESTAMP() with parameter break query cache?

Tags:

database

mysql

I know using UNIX_TIMESTAMP() will cause MySQL to not cache the query, which is reasonable. But, if I use UNIX_TIMESTAMP() to convert a DATETIME-column, will it also miss the cache?

like image 652
Andreas Bergström Avatar asked Mar 24 '26 07:03

Andreas Bergström


1 Answers

It will still be cached if you pass a value or column as a parameter to UNIX_TIMESTAMP().

It is also worth knowing in case you weren't aware, that any changes to your table result in the cache being cleared. So if the table you are querying changes frequently, you probably aren't having much if any benefit of the query cache.

From the 5.5 manual:

A query cannot be cached if it contains any of the functions shown in the following table.
- UNIX_TIMESTAMP() with no parameters

like image 102
drew010 Avatar answered Mar 26 '26 20:03

drew010