Query Hints
/* In the index-tuning module, we hit a wall when we tried to use index tuning
alone to solve a tough choice between two indexes on this proc: */
CREATE OR ALTER PROC dbo.usp_TopScoringPostsByDateAndScore
@StartDate DATETIME, @EndDate DATETIME, @MinimumScore INT AS
BEGIN
SELECT TOP 200 p.Score, p.Title, p.Body, p.Id, p.CreationDate, u.DisplayName
FROM dbo.Posts p
INNER JOIN dbo.Users u ON p.OwnerUserId = u.Id
WHERE p.CreationDate BETWEEN @StartDate AND @EndDate
AND p.Score >= @MinimumScore
ORDER BY p.Score DESC;
END
GOLast updated