Skip to content

Use row comparison in keyset pagination

Adam Hegyi requested to merge use_row_comparison_in_keyset_pagination into master

What does this MR do?

This change uses row comparison in keyset pagination when the ORDER BY columns are not nullable and the order direction is the same.

Thanks, @pbair for suggesting this technique!

Instead of building a complex UNION query we can use: (created_at, id) > ('2012-09-18 01:40:01+00', 15)

There is a tiny performance improvement when using the PG row comparison.

The change does not introduce new functionality, the following test cases are covering the change:

'./spec/lib/gitlab/pagination/keyset/order_spec.rb[1:1:2:1:2:1]' # Gitlab::Pagination::Keyset::Order paginate over items correctly when ordering by two non-nullable columns and a distinct column behaves like order examples when paginating forwards
'./spec/lib/gitlab/pagination/keyset/order_spec.rb[1:1:2:1:2:2:1]' # Gitlab::Pagination::Keyset::Order paginate over items correctly when ordering by two non-nullable columns and a distinct column behaves like order examples when paginating forwards with different page size
'./spec/lib/gitlab/pagination/keyset/order_spec.rb[1:1:2:1:3:1]' 

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Alex Kalderimis

Merge request reports