开发者

Single or multiple column index on date columns best for performance in SQL Server?

开发者 https://www.devze.com 2023-02-22 09:24 出处:网络
In SQL开发者_StackOverflow中文版 Server 2000, is it better to create an index on start and end date columns combined or one index on each one? MySQL handles multiple column indexes in a way that would

In SQL开发者_StackOverflow中文版 Server 2000, is it better to create an index on start and end date columns combined or one index on each one? MySQL handles multiple column indexes in a way that would most likley work fine with both columns in a single index. But I'm unsure how SQL Server handles this.

The idea is to search on a record where the enddate > GIVEN_DATE and also sometimes using startdate < GIVEN_DATE AND enddate > GIVE_DATE.

Since the table I will be adding the index to is quite large and will take some time and keep our system offline during that time I ask here before so I don't have to redo the procedure later ;)


I'll try to create one INDEX on fields ENDDATE + STARTDATE. In this case MS SQL can use this index in queries

.... where ENDADATE > somedate

and on queries

.... where ENDADATE > somedate and  STARTDATE < otherdate

But keep in mind that this index will not be used in queries like

.... where STARTDATE < somedate
0

精彩评论

暂无评论...
验证码 换一张
取 消