I will be looking for distinct values in the
BountyAmountcolumn of the
dbo.Votestable, presented in bounty amount order ascending. The Votes table has just under 53 million rows (52,928,720 to be exact). There are just 19 different bounty amounts, including
The Stack Overflow 2013 database comes without nonclustered indexes to minimize download time. There is a clustered primary key index on the
Idcolumn of the
dbo.Votestable. It comes set to SQL Server 2008 compatibility (level 100), but we will start with a more modern setting of SQL Server 2017 (level 140):
Getting the query down from 10.5 seconds to 1ms is crazy.