Skip to content

Commit

Permalink
perf: remove implicit ordering with take and skip
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky committed Sep 13, 2023
1 parent 09a821d commit 290d2c4
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,9 @@ fn extract_compound_cursor_field(
/// Runs final transformations on the QueryArguments.
fn finalize_arguments(mut args: QueryArguments, model: &Model) -> QueryArguments {
// Check if the query requires an implicit ordering added to the arguments.
// An implicit ordering is convenient for deterministic results for take and skip, for cursor it's _required_
// as a cursor needs a direction to page. We simply take the primary identifier as a default order-by.
let add_implicit_ordering =
(args.skip.as_ref().map(|skip| *skip > 0).unwrap_or(false) || args.cursor.is_some() || args.take.is_some())
&& args.order_by.is_empty();
// An implicit ordering is required for cursor as a cursor needs a direction to page.
// We simply take the primary identifier as a default order-by.
let add_implicit_ordering = args.cursor.is_some() && args.order_by.is_empty();

if add_implicit_ordering {
let primary_identifier = model.primary_identifier();
Expand Down

0 comments on commit 290d2c4

Please sign in to comment.