任务描述

1.问题分析

华为云慢sql top 20,查询时间208.374 秒


2.解决方案


索引优化建议:
  1. 建议在数据表 irobotbox_marketpublish.M_Ebay_Listing_Sub 的 OrderSourceId,EditStatus,CustomerId,QuantitySold,ProductId 列上添加如下索引,以提高查询性能:
    ALTER TABLE `irobotbox_marketpublish`.`M_Ebay_Listing_Sub` ADD INDEX `idx_OrderSourceId_EditStatus_CustomerId_QuantitySold_ProductId` (`OrderSourceId`, `EditStatus`, `CustomerId`, `QuantitySold`, `ProductId`)

注意:在业务高峰期,变更表结构存在风险,请谨慎操作!表数据比较多,下班业务低峰执行


3.慢sql


SELECT `ProductId` AS `ProductId`, SUM(IFNULL(`QuantitySold`, 0)) AS `YearSales`
FROM `M_Ebay_Listing_Sub`
WHERE `CustomerId` = 1
	AND `OrderSourceId` = 10469
	AND `QuantitySold` > 0
	AND `EditStatus` = 1
	AND NOT `ProductId` IN ('364125638437', '364090255207', '364122775869')
GROUP BY `ProductId`
ORDER BY `YearSales` DESC
LIMIT 0, 100
历史记录  
  1. 2023-04-18 15:57:08, 由 陈少军 创建。
  2. 2023-04-18 16:58:29, 由 程伟 编辑。
    修改了 指派给 ,旧值为 "chengwei",新值为 "huxiaofeng"。
    修改了 任务描述,区别为:
    005-
    005+
    006- 索引优化建议:
    006+ 索引优化建议:
    007- 建议在数据表irobotbox_marketpublish.M_Ebay_Listing_Sub的OrderSourceId,EditStatus,CustomerId,QuantitySold,ProductId列上添加如下索引,以提高查询性能:
    007+ 建议在数据表irobotbox_marketpublish.M_Ebay_Listing_Sub的OrderSourceId,EditStatus,CustomerId,QuantitySold,ProductId列上添加如下索引,以提高查询性能:
    009-
    009+
    010- 注意:在业务高峰期,变更表结构存在风险,请谨慎操作!表数据比较多,下班业务低峰执行
    010+ 注意:在业务高峰期,变更表结构存在风险,请谨慎操作!表数据比较多,下班业务低峰执行
    011-
    011+
    012- 3.慢sql
    012+ 3.慢sql
    013-
    013+
    014- SELECT `ProductId` AS `ProductId`, SUM(IFNULL(`QuantitySold`, 0)) AS `YearSales`
    014+ SELECT `ProductId` AS `ProductId`, SUM(IFNULL(`QuantitySold`, 0)) AS `YearSales`
    005- <p>
    005+ <p><br /></p>
    006- </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>
    006+ <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- <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_Ebay_Listing_Sub</span>的<span class="warning_color-PMRVtN" style="color:#FF8833;">OrderSourceId,EditStatus,CustomerId,QuantitySold,ProductId</span>列上添加如下索引,以提高查询性能:
    007+ <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_Ebay_Listing_Sub</span>的<span class="warning_color-PMRVtN" style="color:#FF8833;">OrderSourceId,EditStatus,CustomerId,QuantitySold,ProductId</span>列上添加如下索引,以提高查询性能:
    009- </li>
    009+ </li>
    010- </ol><p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">注意:在业务高峰期,变更表结构存在风险,请谨慎操作!表数据比较多,下班业务低峰执行</p>
    010+ </ol><p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">注意:在业务高峰期,变更表结构存在风险,请谨慎操作!表数据比较多,下班业务低峰执行</p>
    011- <p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';"><br /></p>
    011+ <p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';"><br /></p>
    012- <p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">3.慢sql</p>
    012+ <p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">3.慢sql</p>
    013- <p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';">
    013+ <p class="mt5 ng-binding ng-scope" style="color:#252B3A;font-family:HuaweiFont, Helvetica, Arial, 'PingFangSC-Regular';"><br /></p>
    014- </p><pre class="ng-binding">SELECT `ProductId` AS `ProductId`, SUM(IFNULL(`QuantitySold`, 0)) AS `YearSales`
    014+ <pre class="ng-binding">SELECT `ProductId` AS `ProductId`, SUM(IFNULL(`QuantitySold`, 0)) AS `YearSales`
  3. 2023-04-18 17:23:23, 由 胡笑锋 完成。
    修改了 总计消耗,旧值为 "0",新值为 "1"。
    修改了 指派给 ,旧值为 "huxiaofeng",新值为 "chenshaojun"。
    修改了 实际完成,旧值为 "",新值为 "2023-04-18 17:23:12"。
    修改了 任务状态,旧值为 "wait",新值为 "done"。
    修改了 实际开始,旧值为 "0000-00-00 00:00:00",新值为 "2023-04-18 17:23:23"。
    修改了 由谁完成,旧值为 "",新值为 "huxiaofeng"。
    代码上已做优化
  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 15:57:08
由谁完成 胡笑锋 于 2023-04-18 17:23:12
由谁取消 暂无
由谁关闭 周杰 于 2023-10-31 14:53:16
关闭原因 已完成
最后编辑 周杰 于 2023-10-31 14:53:16
团队 最初预计 总计消耗 预计剩余
工时信息
最初预计 0工时
总计消耗 1工时
预计剩余 0工时
预计开始 2023-04-18
实际开始 2023-04-18
截止日期 2023-04-21