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?
The primary key constraint creates an index (in this example, a clustered index) on the
namecolumn.If you have queries that try to look up the
nameby giving thevalue, you’ll need an index onvaluecolumn to do that efficiently. Otherwise, if all of your lookups are based onname, you don’t need to create an index on thevaluecolumn.