#tempSample is never cleared. So you throw out the same rows over and over in cross apply. Is that intentional?
You also don't need uix_tmpSampleIndex index.
_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths