douyun1950 2009-03-02 15:49
浏览 57

“无限”的sql语句?

I've got a very strange sql-related problem.

I'm accessing a MSSQL Server 2005 with PHP (odbc), when I profile the sql statement the following is executed:

declare @p1 int
set @p1=180150003
declare @p3 int
set @p3=2
declare @p4 int
set @p4=1
declare @p5 int
set @p5=-1
exec sp_cursoropen @p1 output,N'SELECT  fieldA,  fieldB, fieldC, fieldD, fieldE FROM mytable WHERE fieldB IS NULL',@p3 output,@p4 output,@p5 output
select @p1, @p3, @p4, @p5

exec sp_cursorfetch 180150003,2,1,1

On my own server it's working fine, on the customer-server the sp_cursorfetch reads infinite rows and loads the full cpu. When I try to execute the statement itself

SELECT  fieldA,  fieldB, fieldC, fieldD, fieldE FROM mytable WHERE fieldB IS NULL

in SQL Server Management Studio it works fine (under 1sec).

Any ideas?

Edit: the main difference between the servers is that my server is a x86 (Win2003) and the server of the customer is a x64 (Win2008).

Edit2: Added Where-Clause

  • 写回答

5条回答 默认 最新

  • dqxuiq7772 2009-03-02 15:55
    关注

    There's no WHERE clause in that SELECT statement, so you'll be doing a table scan over every row in that table. If your customer has many more rows than your local server, that would explain the time discrepancy.

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line