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

Correlate should override estimateRowCount

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.21.0
    • 1.22.0
    • None

    Description

      Currently, Correlate inherits the estimateRowCount implementation from AbstractRelNode:

      public double estimateRowCount(RelMetadataQuery mq) {
        return 1.0;
      }
      

      which gives a "default" (but unrealistic) row count computation.
      This has several issues:

      • This value may be used by Correlate#computeSelfCost (and by inheritance by LogicalCorrelate / EnumerableCorrelate):
        @Override public RelOptCost computeSelfCost(final RelOptPlanner planner, final RelMetadataQuery mq) {
          double rowCount = mq.getRowCount(this);  // by default: estimateRowCount, i.e. 1.0
          ...
        
      • As the current state, this value will definitely by used by several join algorithms in their cost computation if their left/right child is a Correlate:
        public class EnumerableHashJoin extends Join implements EnumerableRel {
        ...
          @Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
            ...
            final double rightRowCount = right.estimateRowCount(mq); // 1.0 if right is a Correlate
            final double leftRowCount = left.estimateRowCount(mq); // 1.0 if left is a Correlate
            ... 
        

      Even though cost computation is pluggable (which would help solving issues like the first one, but not issues like the second one), IMHO we should provide a more realistic default Correlate#estimateRowCount computation.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            vladimirsitnikov Vladimir Sitnikov
            rubenql Ruben Q L
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m

                Slack

                  Issue deployment