This query (part of a sproc) will be executed quite a lot:
SELECT TOP (@numRecords) BlogPost.postId,BlogPost.creationDate,
BlogPost.header,BlogPost.markedupContentAbstract
FROM dbo.BlogPost ORDER BY BlogPost.creationDate DESC
Should I put an index on the ‘creationDate’ field in the BlogPost table?
Should I have a view where BlogPost records are ordered and then just SELECT TOP from that?
Details: using SQL Server 2008.
You cannot create a view with
ORDER BYunless you add aTOPinto that view.You can create an index on
creationDateand cover all other columns you use in theSELECTlist: