zoukankan      html  css  js  c++  java
  • 一个游标的性能问题

    一个表大概有20来万记录

    使用一个游标,当查询语句中用order by id

    时速度齐慢,计划发现会做多个全表扫描,

    后来采用 先添加到临时表,再做处理解决

    ------------------------速度很慢的sql-----------------

      Declare @DieA char(20)
    Declare @DieB char(20)


    Declare My_Cursor  cursor For
    select isnull(ModuleID1,''),isnull(moduleId2,'') from product_auto_compjo
    where batno='12017307' and barcode='15yuxinjie'
    order by Id

    open my_Cursor

    Fetch My_Cursor
     Into @DieA,@DieB

    While(@@Fetch_Status=0)
    Begin
     --
     --Print @DieA + '|' +@DieB

     --处理下一条记录
     Fetch My_Cursor
     Into @DieA,@DieB
    End

    Close My_Cursor
    deallocate My_cursor

  • 相关阅读:
    ubuntu下使用golang、qml与ubuntu sdk开发桌面应用 (简单示例)
    Go Revel 学习指南
    Go Revel
    Go Revel
    Go Revel
    Go Revel
    Go Revel
    Go Revel
    Go Revel
    Go Revel
  • 原文地址:https://www.cnblogs.com/wdfrog/p/2472014.html
Copyright © 2011-2022 走看看