MySQL-插入需要更多时间

时间:2019-02-16 02:26:43

标签: mysql

MySQL 5.6.40以2.4%的CPU负载运行,但是插入查询花了3秒钟。这是慢查询日志,

# Time: 190216 2:15:06
# Query_time: 3.187892 Lock_time: 3.187890 Rows_sent: 0 Rows_examined: 0
SET timestamp=1550283306;
INSERT INTO worker_job(tenant, type, name, meta, user, status) VALUES('store', 'SWAP', '37943', '37943', 'cf82c458-9eea-4265-967d-51fda645f52f', 'PENDING');

这是表模式,

CREATE TABLE `worker_job` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `tenant` varchar(10) NOT NULL,
  `type` varchar(50) NOT NULL,
  `name` varchar(100) NOT NULL,
  `meta` varchar(1000) DEFAULT NULL,
  `user` varchar(100) DEFAULT NULL,
  `status` enum('PENDING','IN_PROGRESS','FAILED','COMPLETED','CANCELED','WIP') DEFAULT NULL,
  `created_on` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_on` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `message` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_job` (`tenant`,`type`,`name`),
  KEY `idx_wj_s` (`status`)
);

解释输出,

mysql> explain INSERT INTO worker_job(tenant, type, name, meta, user, status) VALUES('store', 'SWAP', '37943', '37943', 'cf82c458-9eea-4265-967d-51fda645f52f', 'PENDING');
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra          |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
|  1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL | No tables used |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+

还有其他因素会影响此写操作吗?

0 个答案:

没有答案