Jason
Jason

Reputation: 61

How to build indexes / optimize for this table

I'm using SQL Server 2008 R2 and I have a table in my database that looks something like this.

Id (Int), Name(NVarChar), DateCreated(DateTime), Message(NVarChar)

Only 3 queries are run against this database table

select top 1 * 
from table1 
where Name = @input   // almost all Names are unique, used 55% of the time

select top 100 
from table1   
where DateCreated > @input    // used 40% of the time

insert...    //create new record, used 5% of the time

This table has over 20 million rows.

How can I optimize this database?

Upvotes: 0

Views: 196

Answers (1)

egze
egze

Reputation: 3236

Add an index on Name and on DateCreated

Upvotes: 1

Related Questions