重现步骤

[步骤]

1. 查询2020年到2021年,维度按年查询时间过长,共花费1.68分钟才加载出来


[结果]


[期望]

1. 优化查询速度
历史记录  
  1. 2022-03-10 17:27:20, 由 刘超 创建。
  2. 2022-03-11 09:37:44, 由 许瑞丰 指派给 陈少军。
    修改了 指派给,旧值为 "xuruifeng",新值为 "chenshaojun"。
    统计的数据量区间过大,销售分析项目还需要熟悉阶段暂无法做更进一步的优化,架构师确认一下可有优化的空间,
  3. 2022-04-28 15:24:03, 由 陈少军 指派给 许瑞丰。
    修改了 指派给,旧值为 "chenshaojun",新值为 "xuruifeng"。

    瑞丰,把查询的sql 和参数贴到这里,我优化一下

    以后性能问题,需要优化的也都贴一下 sql

  4. 2022-04-28 15:51:43, 由 许瑞丰 指派给 李忠红。
    修改了 指派给,旧值为 "xuruifeng",新值为 "lizhonghong"。
  5. 2022-04-28 17:41:50, 由 李忠红 指派给 陈少军。
    修改了 指派给,旧值为 "lizhonghong",新值为 "chenshaojun"。
    部分sql语句:

    select 

    isnull(tmpfee.Profits,0) as OperateFee--毛利润
    ,isnull(tmpfee.SalesRefunds,0) as RefundPrice--退款金额
    ,isnull(tmpfee.SalesPrice,0) as SalesPrice--销售收入
    ,isnull(tmpfee.TransportPay,0) as TransportPay--运费收入
    ,isnull(tmpfee.TaxIncome,0) AS TaxIncome--税费收入
    ,isnull(tmpfee.OtherCredits,0) as OtherIncomeAmount--其他收入
    ,isnull(tmpfee.PromotionRebates,0) as PromotionFee--折扣费
    ,0 as RefundOrderNum
    ,'' as ReportDay 
    from 
    (
    select 
    SUM(s.Profits/s.USD_ExchangeRMB) Profits,
    SUM(s.SalesPrice/s.USD_ExchangeRMB) SalesPrice,
    SUM(s.TransportPay/s.USD_ExchangeRMB) TransportPay,
    SUM(s.SalesRefunds/s.USD_ExchangeRMB) SalesRefunds,
    SUM(s.PromotionRebates/s.USD_ExchangeRMB) PromotionRebates,
    SUM(s.OtherCredits/s.USD_ExchangeRMB) OtherCredits,
    SUM((ISNULL(s.Tax,0)+ISNULL(s.MarketplaceFacilitatorTax,0))/s.USD_ExchangeRMB) as TaxIncome
    FROM RB_Report_OrderSettlement s WITH (NOLOCK)
    --inner join RB_Product p WITH(NOLOCK) on s.SKU=p.SKU and p.CustomerID=1
    WHERE  
    s.CustomerID =1
    --and s.OrderSourceID IN (select item from CharSplitForIn('%s',','))
    and s.PayDate BETWEEN '2021-04-01' AND '2022-04-01'
    --and p.BrandID IN (select item from CharSplitForIn('%s',','))

    ) tmpfee




    go接口 :代码路径:erpapi\pkg\platform\amazon\settlement.go\SalesAnalysisSettlementReportGroup

  6. 2022-04-29 15:57:57, 由 陈少军 添加备注。


    现在一个单表2个条件查询查询,不好优化,把sql  补充全 我在看看优化一下

  7. 2022-04-29 15:59:17, 由 陈少军 指派给 李忠红。
    修改了 指派给,旧值为 "chenshaojun",新值为 "lizhonghong"。


     这个部分sql不好优化,帮把sql 补全,我在看看

  8. 2022-05-03 14:32:42, 由 李忠红 指派给 陈少军。
    修改了 指派给,旧值为 "lizhonghong",新值为 "chenshaojun"。

    select 

    isnull(tmpfee.Profits,0) as OperateFee--毛利润
    ,isnull(tmpfee.SalesRefunds,0) as RefundPrice--退款金额
    ,isnull(tmpfee.SalesPrice,0) as SalesPrice--销售收入
    ,isnull(tmpfee.TransportPay,0) as TransportPay--运费收入
    ,isnull(tmpfee.TaxIncome,0) AS TaxIncome--税费收入
    ,isnull(tmpfee.OtherCredits,0) as OtherIncomeAmount--其他收入
    ,isnull(tmpfee.PromotionRebates,0) as PromotionFee--折扣费
    ,0 as RefundOrderNum
    ,tmpfee.ReportDay as ReportDay
    from
    (
    select
    CONVERT(varchar(10),s.PayDate,120) as ReportDay,
    SUM(s.Profits) Profits,
    SUM(s.SalesPrice) SalesPrice,
    SUM(s.TransportPay) TransportPay,
    SUM(s.SalesRefunds) SalesRefunds,
    SUM(s.PromotionRebates) PromotionRebates,
    SUM(s.OtherCredits) OtherCredits,SUM((ISNULL(s.Tax,0)+ISNULL(s.MarketplaceFacilitatorTax,0))) as TaxIncome
    FROM RB_Report_OrderSettlement s WITH (NOLOCK)

    WHERE   s.CustomerID =1 AND  s.PayDate BETWEEN '2020-01-01' AND '2022-01-01'
    GROUP BY CONVERT(varchar(10),s.PayDate,120)
    ) tmpfee

    SELECT  CONVERT(varchar(10),s.PayDate,120) as ReportDay, COUNT(DISTINCT s.OrderCode) AS RefundOrderNum
    FROM RB_Report_OrderSettlement s with(nolock)
    WHERE s.OrderCode<>'' and s.SalesRefunds<>0  and  s.CustomerID =1 AND  s.PayDate BETWEEN '2020-01-01' AND '2022-01-01' GROUP BY CONVERT(varchar(10),s.PayDate,120)
  9. 2022-05-16 13:40:58, 由 陈少军 解决,方案为 性能问题 。
    修改了 解决方案,旧值为 "",新值为 "performance"。
    修改了 解决版本,旧值为 "",新值为 "569"。
    修改了 解决日期,旧值为 "",新值为 "2022-05-16 13:39:17"。
    修改了 指派给 ,旧值为 "chenshaojun",新值为 "lizhonghong"。
    修改了 Bug状态 ,旧值为 "active",新值为 "resolved"。
    修改了 是否确认,旧值为 "0",新值为 "1"。
    修改了 解决者 ,旧值为 "",新值为 "chenshaojun"。


    优化索引后18 秒执行完成,再验证一下,看看是否够用

  10. 2022-05-16 13:41:33, 由 陈少军 指派给 李忠红。
    修改了 抄送给,旧值为 "",新值为 ",liuchao"。


    优化索引后18 秒执行完成,再验证一下,看看是否够用

  11. 2022-05-16 17:23:10, 由 李忠红 指派给 刘超。
    修改了 指派给,旧值为 "lizhonghong",新值为 "liuchao"。
    修改了 抄送给,旧值为 ",liuchao",新值为 ",xuruifeng"。
    再验证下
  12. 2022-05-17 19:12:40, 由 刘超 添加备注。
    线上观察,测试环境无数据,看不出效果
  13. 2022-05-19 10:10:47, 由 刘超 关闭。
    修改了 Bug状态 ,旧值为 "resolved",新值为 "closed"。
    修改了 指派给 ,旧值为 "liuchao",新值为 "closed"。
    修改了 由谁关闭,旧值为 "",新值为 "liuchao"。
    修改了 关闭日期,旧值为 "",新值为 "2022-05-19 10:10:47"。

所属项目 技术中心-需求池
所属模块 /
所属计划
所属迭代 【智汇】产品部 3月 第1 版本(2022年)
Bug类型 性能问题
严重程度 提示
优先级 P2
Bug状态 已关闭
业务部门
影响功能
开发责任人
测试责任人
解决时效 0
激活次数 0
激活日期
是否确认 是
当前指派 Closed 于 2022-05-19 10:10:47
截止日期 0000-00-00
上线时间
上线时效
操作系统 Windows 10
浏览器 firefox系列
关键词
抄送给 许瑞丰
由谁创建 刘超 于 2022-03-10 17:27:20
影响环境 572
由谁解决 陈少军 于 2022-05-16 13:39:17
解决版本 569
解决方案 性能问题
由谁关闭 刘超 于 2022-05-19 10:10:47
最后修改 刘超 于 2022-05-19 10:10:47
相关Bug