0

我有以下表架构:

CREATE TABLE [Foo](
[id]    [int]       NOT NULL, 
[name]  [varchar(250] NULL,
[datetime_stamp] [datetime]     NULL,
CONSTRAINT [pk_Positions] PRIMARY KEY CLUSTERED 
(   [id] ASC))

假设每天有 n 次插入。每个插入包含 26000 行。对于每个插入,id 是一个唯一值。EG:insert 1,id 1,insert 2,所有行的 id 都是 2。该表有几百万行。如果我想根据时间检索给定插入的行,在 where 子句中使用 datetime_stamp 是否有意义?虽然它没有聚集,但它仍然会一起位于表中。或者有没有更有效的方法来检索给定 n 日期的所有插入?

4

1 回答 1

1

datetime_stamp在列上创建索引。

CREATE INDEX IX_Foo_DatetimeStamp ON Foo(datetime_stamp)
于 2012-04-12T19:36:41.800 回答