The Sorts whose order is lost before it is used (PLAN §11.4), by Sort id, from the query's structure alone: the selection plays no part. Each Sort's order is followed down its chain to the first node that takes rows by it (a Limit, Drop or Slice) or to the chain's end, where it orders the output.

  • A full loss: no key of the Sort is left there. It names the first node whose rows hold none, e.g. a Join, a Restrict that drops every key, or a later Sort on all the same columns.
  • A partial loss: some keys are left, but a node that is not a Sort (a Restrict) lost others first: those whose column its output lacks are removed by it; those whose column it keeps come after a removed one, so they no longer order the rows. Without schemas (the inferred schema of each node), every lost key counts as removed.

A later Sort on some of the same columns is no loss: the others still break its ties. Where the order becomes unknown (an Unknown node), nothing is reported, nor for a Sort without a named key, whose own error shows.