T
T
Timur Gromov2015-10-21 17:43:22
MySQL
Timur Gromov, 2015-10-21 17:43:22

How to speed up query execution?

Greetings, tell me who knows.
There is a table myisam on 3000 records (400 KB), periodically there is a need to update records in the table.
Updated in batches of max 100 records every

INSERT INTO `table` (id, field_varchar, field_int) VALUES (...)
ON DUPLICATE KEY UPDATE field_varchar=VALUES(field_varchar), field_int=VALUES(field_int)

I noticed that if requests are sent at an interval of 0.5-1 seconds, then approximately every third request is executed for 3-5 seconds, which is very long, while the remaining requests are a fraction of a second.
I know the option of how to implement it through memcache, but still I want to figure out why this happens and how to speed up the execution.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Aleksey Ratnikov, 2015-10-21
@tmgrom

It slows down because MyISAM makes a table lock for each such request. Use InnoDB.

M
Max, 2015-10-21
@MaxDukov

"Use INSERT DELAYED when you do not need to know when your data is written. This reduces the overall insertion impact because many rows can be written with a single disk write." maybe try that?

L
lega, 2015-10-21
@lega

See what your IO load is, maybe a gag in this (especially if this is a server from Hetzner).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question