Relative Content

Tag Archive for sqlsqlalchemy

SQLAlchemy LIMIT/OFFSET vs window function

I want to paginate my SQL queries. As far as I know, LIMIT and OFFSET are supposed to be slow for large OFFSET values. I read memory-efficient built-in SqlAlchemy iterator/generator? and https://github.com/sqlalchemy/sqlalchemy/wiki/RangeQuery-and-WindowedRangeQuery to remedy this issue. But these links are talking about iterating over a result set in chunks, not fetching just a portion of the result set. Now my questions are if LIMIT/OFFSET is really slower than using a window function or not in this scenario and If it is, how can I rewrite the solution provided in the GitHub link to fetch a portion of the result by a given range?