在SQL2k降序索引上使用中bug

來源:互聯網
上載者:User
解決SQL2k降序索引上使用對比條件更新或刪除的bug我在SQL server 2000 enterprise 和 personal 都試過了, 每次都這樣。:(
詳細情況看我的回貼:
SQl server 7.0 中的確沒有問題, sql 2000 中(enterprise 和 personal版本都可以),
表要有聚簇索引,並且索引的順序是降序,
例如 按下列DDL sql 建立的表
CREATE TABLE [AType] (
[AID] [int] NOT NULL ,
[name] [varchar(20)] NOT NULL ,
CONSTRAINT [PK_DateType] PRIMARY KEY CLUSTERED
([AID] DESC) ON [PRIMARY] ,
) ON [PRIMARY]
添一些資料後, AID 分別分布在1-100之間
INSERT INTO [AType] VALUES(1,'a')
INSERT INTO [AType] VALUES(50,'b')
INSERT INTO [AType] VALUES(100,'c')

select from atype where Aid < 50
go
delete from Atype where AID < 50
go
select from atype where Aid < 50
最後一句查詢仍然有記錄輸出. :(
by 怡紅公子
報告已經發送給MSSQL開發小組,他們承認這一錯誤。
在沒有新的補丁出來之前,給出以下建議:
不要在單列上使用降序索引,因為這並沒有在效能上帶來好處,僅僅是省略了Order by field desc幾個字而已,用qa的show plan看一下就知道了,不管有沒有order by或者不管是asc還是desc,都沒有這項開銷的(在聚簇索引上)。
降序索引一般是用於複合索引的,這可能是這個bug出現的原因。
原文:
Note that there is no need to create a descending index on a single column because SQL Server can traverse
an ascending index backwards when appropriate. Descending is normally used only in composite indexes.
This is probably why the bug surfaces here

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.