gpt4 book ai didi

mysql - 为什么这个查询被记录为slow_query?

转载 作者:行者123 更新时间:2023-11-29 13:24:06 24 4
gpt4 key购买 nike

我有以下数据库:

CREATE TABLE IF NOT EXISTS `musics` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`active` tinyint(1) NOT NULL DEFAULT '1',
`slug` varchar(50) NOT NULL,
`movie_id` int(11) NOT NULL,
`added` int(11) NOT NULL,
`updated` int(11) NOT NULL,
`featured` tinyint(1) NOT NULL,
`hits` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `slug` (`slug`),
KEY `active` (`active`),
KEY `featured` (`featured`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3339 ;

查询 UPDATE musics SET attempts = 7 WHERE id = '1770' 在音乐专辑的每个页面加载时运行。有什么办法可以优化这个查询吗?

最佳答案

示例..

set global long_query_time=1;

还有,my.cnf

[mysqld]
...
long_query_time=1;

您可以使用“解释”。

explain select * from musics where id = 1770; 

关于mysql - 为什么这个查询被记录为slow_query?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20377900/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com