Reputation: 12410
I'm searching for solution to get current time rounded to minutes without using now() in MySQL. The point of this is get a query which will be handled by Query cache at least for minute. With uses of now() query is changed every second and Query cache isn't used as often as is permitted.
Upvotes: 1
Views: 207
Reputation: 62395
Query cache will never cache queries that use non-deterministic functions, and all time functions are by definition nondeterministic.
Your best option is to build the time string in your application and pass the entire query to MySQL.
A query cannot be cached if it contains any of the functions shown in the following table.
BENCHMARK() CONNECTION_ID() CONVERT_TZ() CURDATE() CURRENT_DATE() CURRENT_TIME() CURRENT_TIMESTAMP() CURTIME() DATABASE() ENCRYPT() with one parameter FOUND_ROWS() GET_LOCK() LAST_INSERT_ID() LOAD_FILE() MASTER_POS_WAIT() NOW() RAND() RELEASE_LOCK() SLEEP() SYSDATE() UNIX_TIMESTAMP() with no parameters USER() UUID() UUID_SHORT()
A query also is not cached under these conditions:
It refers to user-defined functions (UDFs) or stored functions.
It refers to user variables or local stored program variables
[...]
Upvotes: 3