Home Forums SQL Server 2008 T-SQL (SS2K8) Query spills to tempdb with correct cardinality estimates RE: Query spills to tempdb with correct cardinality estimates

  • Your tempdb usage has nothing to do with cardinality estimates. It is because you are ordering by a NVARCHAR(2000) column and the sort operation is spilling to tempdb. Try the query without the order by and you will see that it doesn't spill.

    Edit to add:

    Even changing the column to VARCHAR dropped the memory grant by 1/2 and my laptop was able to do the sort in memory without a spill.

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]