In-operator optimization support for JOINs

The in-operator optimization works only when the ORDER BY columns are located in the same table as defined in the FROM clause.

We have a few use-cases where the in-operator optimization might help improving the performance of database queries where the ORDER BY columns are coming from a JOIN-ed relation.

Related thread with some ideas: !93080 (comment 1053812747)

Task: Extend the in-operator optimization code to support custom Order definitions on JOIN-ed columns.

  • Apply the diffs mentioned in the thread
  • At least three test cases are needed in the query builder test (spec/lib/gitlab/pagination/keyset/in_operator_optimization/query_builder_spec.rb)
    • ORDER BY from_table.column1 ASC, joined_table.column2 ASC
    • ORDER BY from_table.column1 ASC, joined_table.column2 DESC
    • ORDER BY joined_table.column1 ASC, from_table.column2 ASC where joined_table.columnt1 is nullable
  • Add documentation