Mysql low priority query

Is it possible to assign a lower priority to a query in MySQL, similar to the nice command on the command line (on Linux)? If not, are there databases that can do something similar?

+7
mysql
source share
1 answer

You can use LOW_PRIORITY or HIGH_PRIORITY in your queries depending on the type of query being executed:

 INSERT [LOW_PRIORITY | HIGH_PRIORITY] INTO ... SELECT [HIGH_PRIORITY] * FROM ... UPDATE [LOW_PRIORITY] table ... 

From the Mysql 5.7 documentation for an INSERT request for example:

If you use the LOW_PRIORITY keyword, the execution of INSERT is delayed until other clients read from the table. This includes other clients who have started reading while existing clients are reading, and while the INSERT LOW_PRIORITY statement is waiting. Thus, the client can issue an INSERT LOW_PRIORITY statement to wait a very long time.

But it also says:

This only affects storage engines that only use table-level locking (for example, MyISAM, MEMORY, and MERGE).

Thus, you cannot use this function with innodb , for example, if you do not want to use LOCK_TABLES and thereby reduce its performance.

+11
source share

All Articles