Does Mariadb innodb prioritizes Select NOW() over other selects and inserts

29 Views Asked by At

Couldn't find much information on how the select now() query will be executed by mariadb. I believe it has to just read a value that is in memory and return that. So would it prioritize it over any other query?

As per MySQL docs writes are prioritized over reads. Is that also true when the query does not include any table (SELECT NOW();).

Explain and analyze doesn't give insight into how the query will be prioritized.

1

There are 1 best solutions below

2
Rick James On

Short answer: SELECT NOW() is not given priority; It's just fast.

Long answer:

MariaDB can run multiple queries at the same time. If they are not interfering with each other (such as updating the same table), each will finish almost as fast as if it were the only thing running.

Yes, SELECT NOW() (or SELECT 1) is very fast because it has very little to do.

There is no "priority" system. If two transactions get deadlocked, there is a rule for which one will be rolled back and terminated; I would not call that a "priority".

Can you provide a reference to the writes vs reads 'priority'. It may be another case of "what's best for the system".

(This answer applies to MySQL, too.)

LOW_PRIORITY and HIGH_PRIORITY are mostly useless. Or that was my analysis 20 years ago. Note that it does not apply to InnoDB, which is the preferred Engine.