You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vladimir Sitnikov (JIRA)" <ji...@apache.org> on 2019/01/25 22:19:00 UTC

[jira] [Comment Edited] (CALCITE-2223) ProjectMergeRule is infinitely matched when is applied after ProjectReduceExpressionsRule

    [ https://issues.apache.org/jira/browse/CALCITE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16752746#comment-16752746 ] 

Vladimir Sitnikov edited comment on CALCITE-2223 at 1/25/19 10:18 PM:
----------------------------------------------------------------------

It seems the change improves execution time for certain tests.
 It would be interesting to hear if this change introduces a noticeable degradation in plan quality/duration.

For instance: org.apache.calcite.test.JdbcTest#testJoinManyWay improves 7sec -> 3.5sec.
 Note: checkJoinNWay(7) takes 30 seconds before the fix, and with the fix it takes 6-8.
 checkJoinNWay(8) seems to spin forever without the fix, and with the fix it takes 6-8.

Travis tests improve from [1h30m|https://travis-ci.org/apache/calcite/builds/484533821] to [1h22m|https://travis-ci.org/apache/calcite/builds/484543102].


was (Author: vladimirsitnikov):
It seems the change improves execution time for certain tests.
It would be interesting to hear if this change introduces a noticeable degradation in plan quality/duration.

For instance: org.apache.calcite.test.JdbcTest#testJoinManyWay takes improves 7sec -> 3.5sec.
Note: checkJoinNWay(7)  takes 30 seconds before the fix, and with the fix it takes 6-8.
checkJoinNWay(8) seems to spin forever without the fix, and with the fix it takes 6-8.

Travis tests improve from [1h30m|https://travis-ci.org/apache/calcite/builds/484533821] to [1h22m|https://travis-ci.org/apache/calcite/builds/484543102].


> ProjectMergeRule is infinitely matched when is applied after ProjectReduceExpressionsRule
> -----------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2223
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2223
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Volodymyr Vysotskyi
>            Assignee: Julian Hyde
>            Priority: Critical
>         Attachments: heap_overview.png, provenance_contents.png
>
>
> For queries like this:
> {code:sql}
> select t1.f from (select cast(f as int) f, f from (select cast(f as int) f from (values('1')) t(f))) as t1
> {code}
> OOM is thrown when {{ProjectMergeRule}} is applied before applying {{ProjectReduceExpressionsRule}} in VolcanoPlanner.
>  A simple test to reproduce this issue (in {{RelOptRulesTest}}):
> {code:java}
>   @Test public void testOomProjectMergeRule() {
>     RelBuilder relBuilder = RelBuilder.create(RelBuilderTest.config().build());
>     RelNode relNode = relBuilder
>         .values(new String[]{"f"}, "1")
>         .project(
>             relBuilder.alias(
>                 relBuilder.cast(relBuilder.field(0), SqlTypeName.INTEGER),
>                 "f"))
>         .project(
>             relBuilder.alias(
>                 relBuilder.cast(relBuilder.field(0), SqlTypeName.INTEGER),
>                 "f0"),
>             relBuilder.alias(relBuilder.field(0), "f"))
>         .project(
>             relBuilder.alias(relBuilder.field(0), "f"))
>         .build();
>     RelOptPlanner planner = relNode.getCluster().getPlanner();
>     RuleSet ruleSet =
>         RuleSets.ofList(
>             ReduceExpressionsRule.PROJECT_INSTANCE,
>             new ProjectMergeRuleWithLongerName(),
>             EnumerableRules.ENUMERABLE_PROJECT_RULE,
>             EnumerableRules.ENUMERABLE_VALUES_RULE);
>     Program program = Programs.of(ruleSet);
>     RelTraitSet toTraits =
>         relNode.getCluster().traitSet()
>             .replace(0, EnumerableConvention.INSTANCE);
>     RelNode output = program.run(planner, relNode, toTraits,
>         ImmutableList.<RelOptMaterialization>of(), ImmutableList.<RelOptLattice>of());
>     // check for output
>   }
>   /**
>    * ProjectMergeRule inheritor which has
>    * class name greater than ProjectReduceExpressionsRule class name (String.compareTo()).
>    *
>    * It is needed for RuleQueue.popMatch() method
>    * to apply this rule before ProjectReduceExpressionsRule.
>    */
>   private static class ProjectMergeRuleWithLongerName extends ProjectMergeRule {
>     public ProjectMergeRuleWithLongerName() {
>       super(true, RelFactories.LOGICAL_BUILDER);
>     }
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)