简体   繁体   English

Mysql 5.7 Innodb随机删除查询非常慢

[英]Mysql 5.7 Innodb Delete query very slow randomly

I have table with 5 simple fields. 我有5个简单字段的表。 Total rows in table is cca 250. 表中的总行数为cca 250。

When I use PHPmyAdmin with one DELETE query it is processed in 0.05 sec. 当我将PHPmyAdmin与一个DELETE查询一起使用时,它的处理时间为0.05秒。 (always). (总是)。

Problem is that my PHP application (PDO connection) processing same query between other queries and this query is extremely slow (cca 10 sec.). 问题是我的PHP应用程序(PDO连接)在其他查询之间处理相同的查询,并且此查询非常慢(大约10秒钟)。 And another SELECT query on table with 5 rows too (cca 1 sec.). 在表上也有5行的另一个SELECT查询(大约1秒钟)。 It happened only sometimes! 它只是偶尔发生! Other queries (cca 100) are always OK with normal time response. 其他查询(cca 100)始终可以正常响应时间。

What problem should be or how to find what is the problem? 应该是什么问题,或者如何找到问题所在?

Table: 表:

CREATE TABLE `list_ip` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`type` CHAR(20) NOT NULL DEFAULT '',
`address` CHAR(50) NOT NULL DEFAULT '',
`description` VARCHAR(50) NOT NULL DEFAULT '',
`datetime` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00',
PRIMARY KEY (`id`),
INDEX `address` (`address`),
INDEX `type` (`type`),
INDEX `datetime` (`datetime`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB;

Query: 查询:

DELETE FROM list_ip WHERE address='1.2.3.4' AND type='INT' AND datetime<='2017-12-06 08:04:30';

As I said before table has only 250 rows. 正如我之前所说,表只有250行。 Size of table is 96Kib. 桌子的大小是96Kib。 I tested also with empty table and its slow too. 我也用空表测试了它的速度。

Wrap your query in EXPLAIN and see if it's running a sequential select, not using indexes. 在EXPLAIN中包装查询,看看它是否正在运行顺序选择,而不使用索引。 EXPLAIN would be my first stop in determining if I have a data model problem (bad / missing indexes would be one model issue). 在确定我是否有数据模型问题时,EXPLAIN是我的第一站(坏/丢失的索引将是一个模型问题)。

About EXPLAIN: https://dev.mysql.com/doc/refman/5.7/en/explain.html 关于EXPLAIN: https : //dev.mysql.com/doc/refman/5.7/en/explain.html

Another tool I'd recommend is running 'mytop' and looking at the server activity/load during those times when it's bogging down. 我推荐的另一个工具是运行“ mytop”,并在服务器停滞期间检查服务器活动/负载。 http://jeremy.zawodny.com/mysql/mytop/ http://jeremy.zawodny.com/mysql/mytop/

There was some network problem. 网络出现问题。 I uninstalled docker app with some network peripherals and looks much beter. 我用一些网络外围设备卸载了docker app,看起来更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM