开发者

Does table (string, string) require index?

In my 开发者_如何学Cdatabase running on SQL Server 2008 R2 I have a special table for global variables:

CREATE TABLE global_variables
(
    name NVARCHAR(50),
    value NVARCHAR(50) NOT NULL
CONSTRAINT PK_global_variables PRIMARY KEY CLUSTERED
(
    name ASC
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

Does such table require indexing on value or not?


The primary key constraint creates an index (in this example, a clustered index) on the name column.

If you have queries that try to look up the name by giving the value, you'll need an index on value column to do that efficiently. Otherwise, if all of your lookups are based on name, you don't need to create an index on the value column.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜