Skip to content

Ordering of tuples after orderBy operator

ziyi chen edited this page May 17, 2022 · 1 revision

The ordering of tuples can't be guaranteed after the orderBy operator if we multi-threaded the execution of following opeators.

We defined some rules of the behaviour of operators after orderBy:

  1. ORDER BY IN RETURN: the ordering of result tuples is preserved.
  2. ORDER BY IN WITH: Only allow "Top k" type queries with LIMIT and/or SKIP. That is an ORDER BY clause can follow a WITH if and only if there is a LIMIT and/or SKIP following ORDER BY. And if there is a LIMIT and/or SKIP, the LIMIT and SKIP will consume its input/result set according to the given order. But any operator after that ignores the order.

If a query uses ORDER BY IN WITH and is not followed with a LIMIT or SKIP, we error (or we should ignore the ORDER BY clause but ignoring could be harder to do. Erroring is more explicit. Currently, we just make the opeartors after orderby single-threaded.

Clone this wiki locally