I want to select a handful of random rows from the results of a complex query on a very large table (many millions of rows).
I am using SQL Server 2008, and the proper way to do this efficiently seems to be the TABLESAMPLE clause.
Note 1: I am not interested in the popular "order by NEWID()" solution - it is inefficient for large tables.
Note 2: Since my query is complex, I do not want to have to first calculate the COUNT over it, if possible.
Note 3: Since the resultset is huge, I do not want to have to traverse it myself, such as is suggested here.
The kicker is that I am using LINQ. Specifically, LINQ-To-Entities.
Is there a LINQ-friendly way to use TABLESAMPLE?
Even if there is no direct support, is there some way I can write most of my query in LINQ and then do a small amount of manual SQL to perform the TABLESAMPLE?