You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use deferred join to improve pagination performance (#3983)
* Use deferred join to improve pagination performance
When tables have large number of records using LIMIT and larger values for OFFSET result
in inefficient queries today. Instead of performing the pagination on the whole table,
this technique performs the pagination on a subset of the data. The subset is generated
by a subquery that only looks at the ID column (which is indexed) and then rejoins the result
to the original table. This improve DB query times generated by the SequelPaginator on both
MySQL and Postgres.
This technique has been implemented and works for both pagination using OVER window functions and
without.
Sequel gem supports eager loading and eager graph loading which introduces complications for this
technique, therefore we do not yet support this technique for this method.
Additionally, some paginated queries are not generated from a table, but are simply the result of a
subquery, for example Roles is a union of a permissions, we also explicitly do not perform this
technique on these requests as there is no natural ID field that will have been indexed. We only
do deferred joins when the SQL query "FROM" is from a table (e.g. :apps, "apps").
See https://planetscale.com/learn/courses/mysql-for-developers/examples/deferred-joins
* Only remove SequelPaginator tmp field when present
0 commit comments