重现步骤

[步骤]

declare @CustomerID int= 1 ,@VideoGenerateState int= 2 ,@IsUpLoad bit= 0 ,@IsDelete bit= 0 ,@StartTime datetime= '2022/5/1 0:00:00' ,@EndTime datetime= '2024/3/27 23:59:59'
SELECT distinct a.Id,                                             a.DataSource AS VideoType,                                             a.OrderSourceId,                                             c.OrderSourceName,                                             a.OrderSourceCountry,                                             a.Asin as ASIN,                                             a.SKU,                                             CASE                                               WHEN d.id IS NULL THEN 1 --没有策略的默认是腾讯   
ELSE d.ServiceProvider                                             END          AS ServiceProvider,                                                  a.VideoTemplateId,                                             a.VideoTemplateName,                                             f.ID            AS BrandId,                                             e.BrandName,                                             a.VideoUrl,                                             a.OrderSourceSKUID                                      FROM   dbo.RB_ProductVideo_List a with(NOLOCK)                                                  LEFT JOIN dbo.RB_OrderSource c(NOLOCK)                                               ON a.OrderSourceId = c.ID                                                  AND a.CustomerID = c.CustomerID                                             LEFT JOIN dbo.RB_ProductVideo_Strategy_History d(NOLOCK)                                               ON a.CustomerID = d.CustomerID                                                  AND a.BatchId = d.BatchId                                            LEFT JOIN RB_Amazon_Product_Base_Brand e(NOLOCK)  ON a.OrderSourceId=e.OrderSourceId AND a.OrderSourceSKU=e.OrderSourceSKU AND a.CustomerID = e.CustomerId                                         LEFT JOIN dbo.RB_Product_Brand f(NOLOCK) ON e.CustomerId=f.CustomerID AND e.BrandName=f.BrandName AND f.IsActive=1                                      WHERE  a.CustomerID =@CustomerID                                             AND a.VideoGenerateState = @VideoGenerateState                                             AND a.IsUpLoad = @IsUpLoad                                             AND a.IsDelete = @IsDelete                                             AND a.VideoCheckTime >=@StartTime                                                   AND a.VideoCheckTime <=@EndTime  and a.SKU in('16543854','16513508','15882797','16857008','16848393','16513477','16023119','15920974','11704105','16845593','14114052','13303610','15461343','16509209','16114087','15911370','15442922','16844964','11701267','15426448','15889764','13301992','16841857','14094559','15845990','15393252','16838722','16063457','16490646','16035793','14087394','16023359')  



[结果]


[期望]

改善优化查询 提升性能


历史记录  
  1. 2024-03-27 10:54:43, 由 袁慧斌 创建。
  2. 2024-03-27 12:17:25, 由 李乐同 指派给 何建宝。
    修改了 指派给,旧值为 "liletong",新值为 "hejianbao"。
  3. 2024-03-27 13:45:04, 由 何建宝 指派给 吴高发。
    修改了 指派给,旧值为 "hejianbao",新值为 "wugaofa"。
    帮忙看下怎么优化一下
  4. 2024-03-27 15:34:43, 由 吴高发 解决,方案为 性能问题 。
    修改了 解决方案,旧值为 "",新值为 "performance"。
    修改了 解决日期,旧值为 "",新值为 "2024-03-27 15:34:03"。
    修改了 指派给 ,旧值为 "wugaofa",新值为 "hejianbao"。
    修改了 Bug状态 ,旧值为 "active",新值为 "resolved"。
    修改了 是否确认,旧值为 "0",新值为 "1"。
    修改了 解决者 ,旧值为 "",新值为 "wugaofa"。
    DECLARE @CustomerID         INT= 1,
            @VideoGenerateState INT= 2,
            @IsUpLoad           BIT= 0,
            @IsDelete           BIT= 0,
            @StartTime          DATETIME= '2022/5/1 0:00:00',
            @EndTime            DATETIME= '2024/3/27 23:59:59';

    drop table if exists #tabMain;
    SELECT  a.Id,
                    a.DataSource,
                    a.OrderSourceId,                
                    a.OrderSourceCountry,
                    a.Asin       AS ASIN,
                    a.SKU,                
                    a.VideoTemplateId,
                    a.VideoTemplateName,                
                    a.VideoUrl,
                    a.OrderSourceSKUID,
                    a.CustomerID,
                    a.BatchId,
                    a.OrderSourceSKU
                    into #tabMain
    FROM   dbo.RB_ProductVideo_List a WITH(NOLOCK)       
    WHERE  a.CustomerID = @CustomerID
           AND a.VideoGenerateState = @VideoGenerateState
           AND a.IsUpLoad = @IsUpLoad
           AND a.IsDelete = @IsDelete
           AND a.VideoCheckTime >= @StartTime
           AND a.VideoCheckTime <= @EndTime
           AND a.SKU IN( '16543854', '16513508', '15882797', '16857008',
                         '16848393', '16513477', '16023119', '15920974',
                         '11704105', '16845593', '14114052', '13303610',
                         '15461343', '16509209', '16114087', '15911370',
                         '15442922', '16844964', '11701267', '15426448',
                         '15889764', '13301992', '16841857', '14094559',
                         '15845990', '15393252', '16838722', '16063457',
                         '16490646', '16035793', '14087394', '16023359' );

    create index idx_OrderSourceId_BatchId_OrderSourceSKU_CustomerID on #tabMain(OrderSourceId,BatchId,OrderSourceSKU,CustomerID);

    drop table if exists #tabBrand;
    select distinct e.OrderSourceId,e.OrderSourceSKU,e.CustomerId,e.BrandName,f.ID AS BrandId into #tabBrand
    from RB_Amazon_Product_Base_Brand e(NOLOCK)              
     LEFT JOIN dbo.RB_Product_Brand f(NOLOCK)
            ON e.CustomerId = f.CustomerID
                AND e.BrandName = f.BrandName
                AND f.IsActive = 1;
    create index idx_OrderSourceId_OrderSourceSKU_CustomerId on #tabBrand(OrderSourceId,OrderSourceSKU,CustomerId);


    SELECT DISTINCT a.Id,
                    a.DataSource AS VideoType,
                    a.OrderSourceId,
                    c.OrderSourceName,
                    a.OrderSourceCountry,
                    a.Asin       AS ASIN,
                    a.SKU,
                    CASE
                      WHEN d.id IS NULL THEN 1 --没有策略的默认是腾讯   
                      ELSE d.ServiceProvider
                    END          AS ServiceProvider,
                    a.VideoTemplateId,
                    a.VideoTemplateName,
                    e.BrandId,
                    e.BrandName,
                    a.VideoUrl,
                    a.OrderSourceSKUID
    FROM   #tabMain a WITH(NOLOCK)
           LEFT JOIN dbo.RB_OrderSource c(NOLOCK)
                  ON a.OrderSourceId = c.ID
                     AND a.CustomerID = c.CustomerID
           LEFT JOIN dbo.RB_ProductVideo_Strategy_History d(NOLOCK)
                  ON a.CustomerID = d.CustomerID
                     AND a.BatchId = d.BatchId
           left join #tabBrand e        
                  ON a.OrderSourceId = e.OrderSourceId
                     AND a.OrderSourceSKU = e.OrderSourceSKU
                     AND a.CustomerID = e.CustomerId;
    drop table if exists #tabMain;
    drop table if exists #tabBrand;


  5. 2024-03-27 16:32:22, 由 何建宝 指派给 吴万春。
    修改了 指派给,旧值为 "hejianbao",新值为 "wuwanchun"。
  6. 2024-03-27 20:44:58, 由 吴万春 指派给 林鸿贵。
    修改了 指派给,旧值为 "wuwanchun",新值为 "linhonggui"。

    功能:erp webservice 旧版接口 查询sku视频广告数据;

    请求方式:下面这个url链接直接打开:(测正式环境替换域名即可)

    https://test-trunk.zhcxkj.com/Api/Index.ashx?Method=GetProductVideoList&VideoType=0&StartTime=2022-05-01&EndTime=2024-03-27&skus=16543854,16513508,15882797,16857008,16848393,16513477,16023119,15920974,11704105,16845593,14114052,13303610,15461343,16509209,16114087,15911370,15442922,16844964,11701267,15426448,15889764,13301992,16841857,14094559,15845990,15393252,16838722,16063457,16490646,16035793,14087394,16023359

    由于测试环境缺少对应环境,查询sql后面会提示mongodb授权无效,代表前面数据查询没有报错


  7. 2024-03-29 16:28:49, 由 林鸿贵 关闭。
    修改了 Bug状态 ,旧值为 "resolved",新值为 "closed"。
    修改了 指派给 ,旧值为 "linhonggui",新值为 "closed"。
    修改了 由谁关闭,旧值为 "",新值为 "linhonggui"。
    修改了 关闭日期,旧值为 "",新值为 "2024-03-29 16:28:49"。
所属项目 技术中心-需求池
所属模块 供应链   产品采购   产品库
所属计划
所属迭代
Bug类型
严重程度 提示
优先级 P2
Bug状态 已关闭
业务部门
影响功能
开发责任人
测试责任人
解决时效 0
激活次数 0
激活日期
是否确认 是
当前指派 Closed 于 2024-03-29 16:28:49
截止日期 0000-00-00
上线时间
上线时效
操作系统
浏览器
关键词
抄送给
所属迭代
相关需求
相关任务
由谁创建 袁慧斌 于 2024-03-27 10:54:42
影响环境 577
由谁解决 吴高发 于 2024-03-27 15:34:03
解决版本
解决方案 性能问题
由谁关闭 林鸿贵 于 2024-03-29 16:28:49
最后修改 林鸿贵 于 2024-03-29 16:28:49
相关Bug