Babra Cunningham Babra Cunningham - 1 month ago 11
MySQL Question

Concurrent mysql queries causing large query queue's

I have a large mysql database that receives large volumes of queries, each query takes around 5-10 seconds to perform.

Queries involve checking records, updating records and adding records.

I'm experiencing some significant bottle necks in the query executions, which I believe is due to incoming queries having to 'queue' whilst current queries are using records that these incoming queries need to access.

Is there a way, besides completely reformatting my database structure and SQL queries, to enable simultaneous use of database records by queries?

Answer

An INSERT, UPDATE, or DELETE operation locks the relevant tables - myISAM - or rows -InnoDB - until the operation completes. Be sure your query of this type are fastly commited .. and also chechck for you transacation isolating the part with relevant looking ..

Also remeber that in mysql there are differente storage engine with different features eg:

The MyISAM storage engine supports concurrent inserts to reduce contention between readers and writers for a given table: If a MyISAM table has no holes in the data file (deleted rows in the middle), an INSERT statement can be executed to add rows to the end of the table at the same time that SELECT statements are reading rows from the table. https://dev.mysql.com/doc/refman/5.7/en/concurrent-inserts.html

eventually take a look at https://dev.mysql.com/doc/refman/5.7/en/optimization.html