You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Aleksey Plekhanov (Jira)" <ji...@apache.org> on 2022/01/30 08:59:00 UTC

[jira] [Created] (IGNITE-16430) Calcite engine. Sorted index spool with sorting can be planned

Aleksey Plekhanov created IGNITE-16430:
------------------------------------------

             Summary: Calcite engine. Sorted index spool with sorting can be planned
                 Key: IGNITE-16430
                 URL: https://issues.apache.org/jira/browse/IGNITE-16430
             Project: Ignite
          Issue Type: Improvement
            Reporter: Aleksey Plekhanov


Currently, we have code in {{FilterSpoolMergeToSortedIndexSpoolRule}} that creates a sorted spool even if the input collation is empty. In this case, collation is created by index condition and the new sort node is inserted before the spool. But such a plan can never be chosen as the best plan since when we calculate the cumulative cost for the nested loop correlated join, we multiply left side rows count to right side commutative cost not taking into account rewind cost. Currently, cumulative cost for filter + spool = {{{}CPU: n + n{}}}, memory: {{{}0 + n{}}}, for sorted spool + sort = CPU: {{{}log(n) + n*log(n){}}}, memory: \{{n + n}}. So, the cost for filter + spool will always be better than the cost for sorted spool + sort and sorted spool + sort never can be chosen. But for example, for sorted spool with sort rewind CPU cost is only {{log(n)}} since sorting is required only once and rewind CPU cost of filter + spool is {{{}n + n{}}}. So, starting from some iteration count cost of {{iterations * rewind cost + cumulative cost}} will be better than {{{}iterantions * cumulative cost{}}}, and sorted spool + sort will be chosen in this case.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)