In Markus Winand's blog post Pagination done the Postgresql way the following appears on slide 22:
select * from <table> where topic = 1234
and (date, id) < (prev_date, prev_id)
order by date desc, id desc
limit 10;
This uses a composite value (or "row value") in the WHERE
clause, which in 2013 was apparently only supported by Postgres. With correct indexing this should be more efficient than the OFFSET
/LIMIT
anti-pattern.
Is there any way of performing this type of WHERE
clause in a sqlalchemy filter? My searches so far have only found information about composite keys.