Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4157

Use a different sort algorithm for EnumerableDefaults.orderBy(...)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      As shown by the benchmarks for CALCITE-3920, the sort with a TreeMap is slower than sorting with Arrays.sort(Object[]). The latter takes about 35% less time than sorting with TreeMap over a randomized input. While the implementation is not exactly the same, it should be close enough to be able to say something about the performance of EnumerableDefaults.orderBy(...). The relevant results for this issue are the benchmarks with limit=-1 and algorithms treeMap and collectionSort.

      The speedup might be even better if the input is already sorted by chance (i.e., it depends on the actual data during the execution and the planner is not aware that the result would be sorted). Modern VMs use TimSort, which checks if the input is already sorted.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              thomas.rebele Thomas Rebele
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: