http://community.csdn.net/Expert/topic/5744/5744184.xml?temp=4.096621E-02
把应该0秒查询出来的结果,搞了近10秒才查出来。

解决方案 »

  1.   

    Microsoft SQL Server  2000 - 8.00.194 (Intel X86)   Aug  6 2000 00:57:48   Copyright (c) 1988-2000 Microsoft Corporation  Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 1) 
    我同事用的企业版sp1,也有同样的问题。
      

  2.   

    有 CharIndex的比较(字符串的比较),可能会慢.
      

  3.   

    拷过来,看着方便些:select *
    from
    (SELECT p_Product.ProductGUID, ProductName, ProductCode, ProductSpec, Unit, Price, Res
          FROM p_Product 
          left JOIN p_product2type b ON p_Product.productguid = b.productguid
          LEFT JOIN vp_product2unit c ON p_Product.productguid =c.productguid
          left JOIN mybusinessunit d ON c.bucode = d.hierarchycode
          WHERE  (1=1) AND ( CharIndex('01.01.01' + '.',b.ProductTypeCode + '.')=1 )
          AND d.BUGUID=('11b11db4-e907-4f1f-8835-b9daab6e1f23')
    ) p_Product
    结果集有18条记录。执行时间:76 msselect *
    from
    (SELECT p_Product.ProductGUID, ProductName, ProductCode, ProductSpec, Unit, Price, Res
          FROM p_Product 
          left JOIN p_product2type b ON p_Product.productguid = b.productguid
          LEFT JOIN vp_product2unit c ON p_Product.productguid =c.productguid
          left JOIN mybusinessunit d ON c.bucode = d.hierarchycode
          WHERE  (1=1) AND ( CharIndex('01.01.01' + '.',b.ProductTypeCode + '.')=1 )
          AND d.BUGUID=('11b11db4-e907-4f1f-8835-b9daab6e1f23')
    ) p_Product
    ORDER BY p_Product.ProductCode ASC,p_Product.ProductGUID
    结果集:还是18条记录。 执行时间:9733 ms
    想不通为什么会差别那么大,仅仅排18条记录的序,就要费那么长时间吗?---补充说明:mybusinessunit 表有24条记录,其他表都是3000条记录。
    主要原因还是它把sql语句改了,从查询计划上看到,它把语句改成下面的样式,但是就是下面的语句执行起来也只有5秒左右,也不会那么慢呀。
    SELECT  p_Product.ProductGUID, ProductName, ProductCode, ProductSpec, Unit, Price, Res
    from
    (select top 100000000  p_Product.ProductGUID, ProductName, ProductCode, ProductSpec, Unit, Price, Res,d.bucode
    from p_Product
    LEFT JOIN vp_product2unit c ON p_Product.productguid =c.productguid
    left JOIN mybusinessunit d ON c.bucode = d.hierarchycode
    where d.BUGUID=('11b11db4-e907-4f1f-8835-b9daab6e1f23')
    order by p_Product.ProductCode ASC,p_Product.ProductGUID
    )
    p_Product
    left JOIN mybusinessunit d ON p_Product.bucode = d.hierarchycode
    left JOIN p_product2type b ON p_Product.productguid = b.productguid
    where ( CharIndex('01.01.01' + '.',b.ProductTypeCode + '.')=1 )
      

  4.   

    ORDER BY 是会浪费很多时间的这些表关键还是要看索引建立的如何,虽然数据不多,可是 join 的表也很多
      

  5.   

    我打了
    SQL2000-KB884525-SP4-x86-CHS.exe
    再查看版本还是sp1.不知道哪儿有对应的补丁呀。
    微软网站上也没找到。
      

  6.   

    你還是sp1,現在都是sp4 了,快打上吧
      

  7.   

    http://www.microsoft.com/downloads/details.aspx?FamilyID=8e2dfc8d-c20e-4446-99a9-b7f0213f8bc5&DisplayLang=zh-cn
      

  8.   

    我打了
    SQL2000-KB884525-SP4-x86-CHS.exe
    再查看版本还是sp1.不知道哪儿有对应的补丁呀。
    微软网站上也没找到。
    -----------------------
    google一下,很多的
      

  9.   

    没打补丁?
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  10.   

    打了没打上?SQL2000-KB884525-SP4-x86-CHS.EXE 是从官网下的吗官网下的MD5指纹应该是:3ad18117fcdc6c80cd76d6052af25fd1
      

  11.   

    谢谢Limpire(昨夜小楼)
    不是从官网上下的,位是md5码和你的一样,原因是我的版本是开发版。
    我以前在企业版上打补丁,一下就打上了,从没出过问题。
    是开发版的补丁和企业版不一样吧。
      

  12.   

    开发版~没有用过哦~
    但时间变多不全是补丁的问题吧?
    就因为一个order by?
    学习!
      

  13.   

    是用同一个补丁呀,怎么没打上,就不知道了。/*
    更新信息:Microsoft 在 SP4 的最终内部版本中发现了一个问题,如果用户在运行 SQL Server 时启用了 AWE 支持功能,就会受到该问题的影响。此问题对 ia64 平台没有影响。在 x86 和 x64 系统上,该问题只会影响符合以下条件的用户:已经启用 AWE 并占用了超出 2 GB 的内存(仅适用于 Enterprise、Developer 和 Evaluation 版本)
    */
      

  14.   

    双击下载的文件,执行的是解压缩, 不是安装
    安装是到解压的目录中去执行 setup.bat
      

  15.   

    双击下载的文件,执行的是解压缩, 不是安装
    安装是到解压的目录中去执行 setup.bat
    ---------------------------------------
    还是邹老大正解,
      

  16.   

    还是用oracle吧用server 用的很爽
      

  17.   

    我的操作系统是winServer2003,更新步骤没有错。
      

  18.   

    楼主:
    会不会是你的P_PORDUCT 等报表记录很多(虽然筛选的结果不多)?
    试试这样做:
    把这段语句……FROM p_Product 
          left JOIN p_product2type b ON p_Product.productguid = b.productguid……
    改成:……FROM p_Product order by productguid) a left join (select   FROM P_PORDUCT2TYPE ORDRE BY PRODUCTCODE) B……