讨论 技术讨论 数据库慢日志记录了大量这样的,要怎么办。

数据库慢日志记录了大量这样的,要怎么办。

fkenuiabcd 发表于    阅读:200    回复:4

数据库慢日志记录了大量这样的,要怎么办。

# User@Host: wwwhzcom[wwwcom] @ localhost [127.0.0.1]  Id: 26914

# Query_time: 3.330494  Lock_time: 0.000200 Rows_sent: 0  Rows_examined: 88962

SET timestamp=1725680049;

select `id`, `hash`, `created_at`, `memberUserId`, `categoryId`, `title`, `description`, `status`, `convertStatus`, `cover`, `pageCount`, `viewCount`, `commentCount`, `scoreAvg`, `downloadCount`, `favoriteCount`, `likeCount`, `viewCountBase`, `downloadCountBase`, `favoriteCountBase`, `likeCountBase`, `vipFreeDownloadEnable`, `creditCost`, `moneyCost`, `rateAvg`, `tags`, `previewData`, `ext`, `fileSize`, `pagePreviews` from `mzwenku_doc` where (`status` = '5' and `isDeleted` = '0') and `categoryId` in ('9', '4', '39', '29', '30', '58', '65') and (select count(*) from `mzwenku_doc_cat_map` where `mzwenku_doc_cat_map`.`docId` = `mzwenku_doc`.`id` and (`catId` = '20')) >= 1 and (select count(*) from `mzwenku_doc_cat_map` where `mzwenku_doc_cat_map`.`docId` = `mzwenku_doc`.`id` and (`catId` = '40')) >= 1 and (select count(*) from `mzwenku_doc_cat_map` where `mzwenku_doc_cat_map`.`docId` = `mzwenku_doc`.`id` and (`catId` = '133')) >= 1 and (select count(*) from `mzwenku_doc_cat_map` where `mzwenku_doc_cat_map`.`docId` = `mzwenku_doc`.`id` and (`catId` = '142')) >= 1 and (select count(*) from `mzwenku_doc_cat_map` where `mzwenku_doc_cat_map`.`docId` = `mzwenku_doc`.`id` and (`catId` = '144')) >= 1 and `ext` in ('doc', 'docx') order by `id` desc limit 24 offset 0;


评论

升级数据库,索引已经优化了,辅助分类用多了是这样的

 

@ModStart:   数据库怎么升级


 

给数据库独立的服务器,升级为8C16G、16C32G,根据数据量大小来调整。

 

我现在都把辅助分类全部删除,辅助分类很耗资源

 
1
我来评论
QQ
微信
客服