Reverse and incremental index sorting optimizations #4041
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ASC NULLS FIRST
index can be used forASC NULLS FIRST
andDESC NULLS LAST
, but it cannot be used forASC NULLS LAST
orDESC NULLS FIRST
. A multi-column index can be used for the same multi-columnORDER BY
only if all column are specified with the same order as in the index, or all columns are specified in reverse order. Due to (2) some indexes where not all columns have the same order can still be used.ORDER BY
clause now may still be used for sorting with an index. It is important for queries with theFETCH
clause, because such queries can stop their execution earlier. We need to read additional rows only until a change in the matched indexed columns, all remaining rows aren't needed. This is similar to existing optimization forWITH TIES
clause.ORDER BY _ROWID_ DESC
is fixed, now it really returns rows in descending order.