任务描述

1.问题分析


慢sql,查询155.906秒; 缺少索引


2.解决方案


索引优化建议:
  1. 建议在数据表 irobotbox_marketpublish.M_Mercadolibre_Notiftransfer_Site 的 UserId,Status,SiteId 列上添加如下索引,以提高查询性能:
    ALTER TABLE `irobotbox_marketpublish`.`M_Mercadolibre_Notiftransfer_Site` ADD INDEX `idx_UserId_Status_SiteId` (`UserId`, `Status`, `SiteId`)

注意:在业务高峰期,变更表结构存在风险,请谨慎操作!


3.慢sql


SELECT `Id` AS `Id`, `UserId` AS `UserId`, `ApplicationId` AS `ApplicationId`, 2 AS `Type`, `SiteId` AS `Resource`
	, `Status` AS `Status`, `SentTime` AS `Sent`, `SentTime` AS `Received`
FROM `M_Mercadolibre_Notiftransfer_Site`
WHERE `UserId` = '1165164882'
	AND `Status` = 0
	AND NOT (`SiteId` IS NULL
	OR `SiteId` = '')
GROUP BY `SiteId`, `UserId`
ORDER BY Id DESC
LIMIT 400, 200


历史记录  
  1. 2023-04-18 16:25:19, 由 陈少军 创建。
  2. 2023-04-19 08:50:24, 由 程伟 编辑。
    修改了 指派给 ,旧值为 "chengwei",新值为 "yaojieyuan"。
    修改了 任务描述,区别为:
    006-
    006+
    007- 索引优化建议:
    007+ 索引优化建议:
    008- 建议在数据表irobotbox_marketpublish.M_Mercadolibre_Notiftransfer_Site的UserId,Status,SiteId列上添加如下索引,以提高查询性能:
    008+ 建议在数据表irobotbox_marketpublish.M_Mercadolibre_Notiftransfer_Site的UserId,Status,SiteId列上添加如下索引,以提高查询性能:
    010-
    010+
    011- 注意:在业务高峰期,变更表结构存在风险,请谨慎操作!
    011+ 注意:在业务高峰期,变更表结构存在风险,请谨慎操作!
    012-
    012+
    013-
    013+ 3.慢sql
    014- 3.慢sql
    014+
    015-
    015+ SELECT `Id` AS `Id`, `UserId` AS `UserId`, `ApplicationId` AS `ApplicationId`, 2 AS `Type`, `SiteId` AS `Resource`
    016- SELECT `Id` AS `Id`, `UserId` AS `UserId`, `ApplicationId` AS `ApplicationId`, 2 AS `Type`, `SiteId` AS `Resource`
    016+ , `Status` AS `Status`, `SentTime` AS `Sent`, `SentTime` AS `Received`
    017- , `Status` AS `Status`, `SentTime` AS `Sent`, `SentTime` AS `Received`
    017+ FROM `M_Mercadolibre_Notiftransfer_Site`
    018- FROM `M_Mercadolibre_Notiftransfer_Site`
    018+ WHERE `UserId` = '1165164882'
    019- WHERE `UserId` = '1165164882'
    019+ AND `Status` = 0
    020- AND `Status` = 0
    020+ AND NOT (`SiteId` IS NULL
    021- AND NOT (`SiteId` IS NULL
    021+ OR `SiteId` = '')
    022- OR `SiteId` = '')
    022+ GROUP BY `SiteId`, `UserId`
    023- GROUP BY `SiteId`, `UserId`
    023+ ORDER BY Id DESC
    024- ORDER BY Id DESC
    024+ LIMIT 400, 200
    025- LIMIT 400, 200
    025+
    026-
    027-
    006- <p>
    006+ <p><br /></p>
    007- </p><div class="sql_tuning_advice_title-3b3aBp" style="margin:10px 0px 5px;padding:0px;color:#FF8833;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">索引优化建议:</div>
    007+ <div class="sql_tuning_advice_title-3b3aBp" style="margin:10px 0px 5px;padding:0px;color:#FF8833;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">索引优化建议:</div>
    008- <ol class="ng-scope" style="margin-left:0px;color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';"><li class="ng-binding ng-scope">建议在数据表<span class="warning_color-PMRVtN" style="color:#FF8833;">irobotbox_marketpublish.M_Mercadolibre_Notiftransfer_Site</span>的<span class="warning_color-PMRVtN" style="color:#FF8833;">UserId,Status,SiteId</span>列上添加如下索引,以提高查询性能:
    008+ <ol class="ng-scope" style="margin-left:0px;color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';"><li class="ng-binding ng-scope">建议在数据表<span class="warning_color-PMRVtN" style="color:#FF8833;">irobotbox_marketpublish.M_Mercadolibre_Notiftransfer_Site</span>的<span class="warning_color-PMRVtN" style="color:#FF8833;">UserId,Status,SiteId</span>列上添加如下索引,以提高查询性能:
    010- </li>
    010+ </li>
    011- </ol><p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">注意:在业务高峰期,变更表结构存在风险,请谨慎操作!</p>
    011+ </ol><p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">注意:在业务高峰期,变更表结构存在风险,请谨慎操作!</p>
    012- <p><br /></p>
    012+ <p><br /></p>
    013-
    013+ <p>3.慢sql</p>
    014- <p>3.慢sql</p>
    014+ <p><br /></p>
    015- <p>
    015+ <pre class="ng-binding">SELECT `Id` AS `Id`, `UserId` AS `UserId`, `ApplicationId` AS `ApplicationId`, 2 AS `Type`, `SiteId` AS `Resource`
    016- </p><pre class="ng-binding">SELECT `Id` AS `Id`, `UserId` AS `UserId`, `ApplicationId` AS `ApplicationId`, 2 AS `Type`, `SiteId` AS `Resource`
    016+ , `Status` AS `Status`, `SentTime` AS `Sent`, `SentTime` AS `Received`
    017- , `Status` AS `Status`, `SentTime` AS `Sent`, `SentTime` AS `Received`
    017+ FROM `M_Mercadolibre_Notiftransfer_Site`
    018- FROM `M_Mercadolibre_Notiftransfer_Site`
    018+ WHERE `UserId` = '1165164882'
    019- WHERE `UserId` = '1165164882'
    019+ AND `Status` = 0
    020- AND `Status` = 0
    020+ AND NOT (`SiteId` IS NULL
    021- AND NOT (`SiteId` IS NULL
    021+ OR `SiteId` = '')
    022- OR `SiteId` = '')
    022+ GROUP BY `SiteId`, `UserId`
    023- GROUP BY `SiteId`, `UserId`
    023+ ORDER BY Id DESC
    024- ORDER BY Id DESC
    024+ LIMIT 400, 200</pre>
    025- LIMIT 400, 200</pre>
    025+ <p><br /></p>
    026-
    027- <p><br /></p>
  3. 2023-04-19 10:58:47, 由 姚杰远 完成。
    修改了 总计消耗,旧值为 "0",新值为 "0.5"。
    修改了 指派给 ,旧值为 "yaojieyuan",新值为 "chenshaojun"。
    修改了 实际完成,旧值为 "",新值为 "2023-04-19 10:58:36"。
    修改了 任务状态,旧值为 "wait",新值为 "done"。
    修改了 实际开始,旧值为 "0000-00-00 00:00:00",新值为 "2023-04-19 10:58:47"。
    修改了 由谁完成,旧值为 "",新值为 "yaojieyuan"。
  4. 2023-10-31 14:53:16, 由 周杰 关闭。
    修改了 任务状态,旧值为 "done",新值为 "closed"。
    修改了 指派给 ,旧值为 "chenshaojun",新值为 "closed"。
    修改了 由谁关闭,旧值为 "",新值为 "zhoujie"。
    修改了 关闭时间,旧值为 "0000-00-00 00:00:00",新值为 "2023-10-31 14:53:16"。
    修改了 关闭原因,旧值为 "",新值为 "done"。
所属迭代 系统管理部 - 系统服务优化
所属模块 /
相关需求 暂无
指派给 Closed 于 2023-10-31 14:53:16
任务类型 后端
任务标签 初始
开发组 有品开发组
任务状态 已关闭
进度 100%
优先级 P2
关键词
抄送给 许瑞丰
由谁创建 陈少军 于 2023-04-18 16:25:19
由谁完成 姚杰远 于 2023-04-19 10:58:36
由谁取消 暂无
由谁关闭 周杰 于 2023-10-31 14:53:16
关闭原因 已完成
最后编辑 周杰 于 2023-10-31 14:53:16
团队 最初预计 总计消耗 预计剩余
工时信息
最初预计 0工时
总计消耗 0.5工时
预计剩余 0工时
预计开始 2023-04-18
实际开始 2023-04-19
截止日期 2023-04-21