2
我用下面我已經展示了一個表的SQL Server 2012的具有多個字段創建索引
,
create table myTable
(
Id int identity(1, 1) constraint PK_myTable primary key(Id),
DateEntry date,
FundCode nvarchar(10),
Sedol nvarchar(7),
Name nvarchar(150),
Nominal int,
PriceDate date,
Price float,
PriceCcy nvarchar(3),
PriceSource nvarchar(30)
)
所以大多數選擇查詢將在dateEntry場&的FundCode場。
所以我決定在下面創建兩個索引。我想知道,如果我們可以假設每個選擇查詢將有一個DateEntry作爲where子句的一部分,那麼第一個索引是否需要?因爲如果FundCode沒有提供,它仍然可以使用第二個索引或者是不正確的?
create index IX_tblEQ_Holdings_Date on tblFI_Holdings(DateEntry)
create index IX_tblEQ_Holdings_DateFund on tblFI_Holdings(DateEntry, FundCode)