Skip to content
Advertisement

Keyset pagination with WHERE & HAVING

I ran into a question that I can’t find a solution yet for keyset pagination:

Suppose we have this query:

How should we do keyset pagination on that?

For a.number only, we can have WHERE a.number < ?; For rating only, we do HAVING rating < ?; If there’re two conditions for where, we can have WHERE (x, y) < (?, ?).

But how to do both HAVING and WHERE?

Edit: I implemented this today and found out that it’s slower than OFFSET pagination, so not recommended.

Advertisement

Answer

The where you never can use, because it can’_t access rating.

What you can do is

HAVING (x, y) < (1, 1)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement