Le clausole HIGH_PRIORITY e LOW_PRIORITY

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

InnoDB/XtraDB usa il locking a livello di riga per garantire l'integrità dei dati. Tuttavia alcuni Storage Engine (come MEMORY, MyISAM, Aria, MERGE) acquisiscono i lock sull'intera tabella per evitare i conflitti. Questi Storage Engine usano due code distinte per ricordare le istruzioni in attesa: una per le SELECT e l'altra per i comandi di scrittura (INSERT, DELETE, UPDATE). Per default, quest'ultima ha una priorità più elevata.

Per dare alle operazioni di scrittura una priorità più bassa, è possibile impostare la variabile low_priority_updates a ON. Questa opzione esiste sia a livello globale sia a livello di sessione, e può essere impostata sia all'avvio sia con l'istruzione SET.

Quando le istruzioni di scrittura impostano troppi lock a livello di tabella, alcune SELECT in attesa vengono eseguite. Il numero massimo dei lock in scrittura che possono essere acquisiti prima che ciò accada è determinato dalla variabile max_write_lock_count, che è dinamica.

If write statements have a higher priority (default), the priority of individual write statements (INSERT, REPLACE, UPDATE, DELETE) can be changed via the LOW_PRIORITY attribute, and the priority of a SELECT statement can be raised via the HIGH_PRIORITY attribute. Also, LOCK TABLES supports a LOW_PRIORITY attribute for WRITE locks.

If read statements have a higher priority, the priority of an INSERT can be changed via the HIGH_PRIORITY attribute. However, the priority of other write statements cannot be raised individually.

The use of LOW_PRIORITY or HIGH_PRIORITY for an INSERT prevents the concurrent INSERTs to be used.

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.