There is a table in our database
tblCustomText(
ParentID int NOT NULL,
CustomFieldID int NOT NULL,
Value char(50) NOT NULL,
Log_CreateDate datetime NOT NULL
)
(ParentID+CustomFieldID) is unique.
Read operations are like: SELECT Value WHERE ParenID=@p1 AND CustomFieldID = @p2 (sometimes instead of WHERE, JOIN is used)
Write operations: 85% is INSERT, 13% is UPDATE, 2% DELETE. (By ParentID+CustomFieldID)
Now, I'd like to know what indexes should be defined for this table? (It contains ~6M rows)
char(50)for the value column. Are these values always going to be exactly 50 characters? If not, I strongly recommendvarcharand verifying that 50 is the right upper limit. I'd also verify that you will never need to support Unicode in this column - I would probably usenvarcharto be safe. On 2008 R2 and up, data compression will help you negate the extra costs of storing non-Unicode data innvarcharcolumns. – Aaron Bertrand Feb 17 '12 at 13:39