Sorting asc vs. desc performance in views and N1QL
We know that the views sort data in ascending order. Since N1QL uses views behind the scenes, we assume that ORDER BY in asc is performant. How does N1QL handle ORDER BY desc? Is there a difference in performance?
For example in SQL relational database when an index is created, one can specify the order (asc / desc). Is there something similar in N1QL? In particular for paging results, does it stop searching once it reaches the LIMIT or does it have to go through the whole index prior to sorting both for asc and desc.
It would also be helpful to know the type / name of the indexing algorithm that is being used.
N1QL currently re-sorts the results, so there is no distinction in performance between ASC and DESC.
The view index is used to identify the range of matching documents. Once these documents are identified, all further processing happens inside the N1QL engine.
View indexes use a b-tree based algorithm and data structure for index maintenance and traversal.
N1QL uses a quicksort for sorting operations.