I have a query that returns 10000's of records that are used as plot points on a map. In an effort to reduce load, and increase app speed we're trying to implement what basically amounts to Level of Detail logic. Basically, when zoomed out, display 50% of the points. When zoomed in, display 100% of the points.
This is ultimately what I need the final SQL to look like:
SELECT *
FROM
(SELECT
[t0].[RecordName],
[t0].[LastMaintenanceDate]
,Row_Number() OVER (ORDER BY [t0].Ticker) as RowNumber
FROM
[dbo].[TableName] AS [t0]
)as [t1]
WHERE RowNumber % 2 = 0
In LINQ I can use .Skip and .Take to get the Row_Number() Over part (example here), but when doing this, the Where criteria generated uses 'between' instead of the "where RowNumber % 2 = 0" that I need.
Am I approaching this correctly? In order to gain the full performance gains we're looking for here, this exclusion really needs to happen on the SQL server.