views:

26

answers:

1

In my database 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?

+6  A: 

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.

Mehrdad Afshari
Sorry, I did a typo. `value`, of course, not `name`
abatishchev