I have a SQL query that looks like this:
SELECT foo \"c0\",
bar \"c1\",
baz \"c2\",
...
FROM some_table
WHERE ...
I
Okay, this will perform worse than what you were planning, but my point is that you could try pagination this way:
WITH CTE AS
(
... original SQL goes here ...
)
SELECT A.*
FROM CTE A
INNER JOIN (SELECT YourKey,
ROW_NUMBER() OVER (ORDER BY ...) rnum
FROM CTE) B
ON A.YourKey = B.YourKey
WHERE rnum BETWEEN 1 AND 10;