zoukankan      html  css  js  c++  java
  • SQLSERVER链接服务查询快,更新慢问题(未能创建可接受的游标后续)

     CREATE TABLE #t1
        (
          id INT IDENTITY(1, 1)
                 NOT NULL ,
          BH INT
        )
    INSERT  INTO #t1
            SELECT  492417420  
    SELECT  *
    FROM    #t1
                             
                  
    DROP TABLE  #t1     
                           
     --更新一条数据 ,实际上更新影响0行                     
     --4秒                     
    UPDATE  test.[sgoa_data].[dbo].[nsb]
    SET     flag = 1  FROM
    test.[sgoa_data].[dbo].[nsb] AS a    JOIN (SELECT B.bh FROM    test.[sgoa_data].[dbo].[nsb] AS B ,
            #t1 AS C  
    WHERE   B.bh = C.bh) E
     ON   a.bh = E.bh  


    --25秒
    UPDATE  test.[sgoa_data].[dbo].[nsb]
    SET     flag = 1  FROM
    test.[sgoa_data].[dbo].[nsb] AS a   ,
            #t1 AS b
    WHERE   a.bh = b.bh

     

    SELECT A.* FROM       test.[sgoa_data].[dbo].[nsb] AS a    JOIN (SELECT B.* FROM    test.[sgoa_data].[dbo].[nsb] AS B ,
            #t1 AS C
    WHERE   B.bh = C.bh) E
            
    ON   a.bh = E.bh  

    问题处理

    --0秒

    UPDATE  a
    SET     flag = 1
    FROM    LINK_39.SGOA_DATA.dbo.NSB AS a
            JOIN ( SELECT  DISTINCT
                            b.bh
                   FROM     LINK_39.SGOA_DATA.dbo.NSB AS B ,
                            #t1 AS C
                   WHERE    B.bh = C.bh
                 ) E ON a.bh = E.bh


                                 
                           
     
     

  • 相关阅读:
    用到了yii2 hasMany() 方法,一对多关联
    jquery操作select标签change事件
    Yii2如何批量添加数据
    [bzoj1497][NOI2006]最大获利
    [bzoj]2962序列操作
    洛谷 P1350 车的放置
    洛谷 P1142 轰炸
    初级数论练习题
    洛谷 P3795 钟氏映射
    洛谷 2953 [USACO09OPEN]牛的数字游戏Cow Digit Game
  • 原文地址:https://www.cnblogs.com/qanholas/p/2418928.html
Copyright © 2011-2022 走看看