Skip to content

Make EXPLAIN print local cost + Do not print Estimates line when estimates are absent#14268

Merged
sopel39 merged 2 commits intotrinodb:masterfrom
starburstdata:ks/do_not_print_Estimates
Sep 28, 2022
Merged

Make EXPLAIN print local cost + Do not print Estimates line when estimates are absent#14268
sopel39 merged 2 commits intotrinodb:masterfrom
starburstdata:ks/do_not_print_Estimates

Conversation

@sopel39
Copy link
Copy Markdown
Member

@sopel39 sopel39 commented Sep 23, 2022

Show local cost in EXPLAIN.

https://github.com/trinodb/trino/commit/e438e1ef8becdf84c320b07615b1f99e915e2b19
changed cost calculations to be cumulative.
However, EXPLAIN still used PlanCostEstimate for
showing plan node cost.
This commit makes EXPLAIN use local cost.
Do not print Estimates line when estimates are absent

Copy link
Copy Markdown
Member

@raunaqmorarka raunaqmorarka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a test

@sopel39 sopel39 force-pushed the ks/do_not_print_Estimates branch from efb0ffc to 16cda87 Compare September 23, 2022 11:15
@sopel39 sopel39 changed the title Do not print Estimates line when estimates are absent Make EXPLAIN print local cost + Do not print Estimates line when estimates are absent Sep 23, 2022
@sopel39
Copy link
Copy Markdown
Member Author

sopel39 commented Sep 23, 2022

please add a test

It's hard to add a test since in every query there is at least one Estimate: line due to cost calculator:

        @Override
        public PlanCostEstimate visitOutput(OutputNode node, Void context)
        {
            return costForStreaming(node, LocalCostEstimate.zero());
        }

I think we could skip it here

@sopel39
Copy link
Copy Markdown
Member Author

sopel39 commented Sep 23, 2022

fyi: @findepi

@sopel39 sopel39 force-pushed the ks/do_not_print_Estimates branch from 16cda87 to a73e713 Compare September 23, 2022 11:18
@sopel39 sopel39 force-pushed the ks/do_not_print_Estimates branch from a73e713 to d156bde Compare September 27, 2022 15:33
trinodb@e438e1e
changed cost calculations to be cumulative.
However, EXPLAIN still used PlanCostEstimate for
showing plan node cost.
This commit makes EXPLAIN use local cost.

after (take a look at Aggregate operator cpu cost):
trino> explain select count(orderkey) from hive.tpch_sf10_orc.lineitem;
                                      Query Plan
---------------------------------------------------------------------------------------
 Fragment 0 [SINGLE]
     Output layout: [count]
     Output partitioning: SINGLE []
     Output[columnNames = [_col0]]
     │   Layout: [count:bigint]
     │   Estimates: {rows: 1 (9B), cpu: 0, memory: 0B, network: 0B}
     │   _col0 := count
     └─ Aggregate[]
        │   Layout: [count:bigint]
        │   Estimates: {rows: 1 (9B), cpu: 514.86M, memory: 9B, network: 0B}
        │   count := count("orderkey")
        └─ LocalExchange[partitioning = SINGLE]
           │   Layout: [orderkey:bigint]
           │   Estimates: {rows: 59986052 (514.86MB), cpu: 0, memory: 0B, network: 0B}
           └─ RemoteSource[sourceFragmentIds = [1]]
                  Layout: [orderkey:bigint]
                  Estimates:

 Fragment 1 [SOURCE]
     Output layout: [orderkey]
     Output partitioning: SINGLE []
     TableScan[table = hive:tpch_sf10_orc:lineitem]
         Layout: [orderkey:bigint]
         Estimates: {rows: 59986052 (514.86MB), cpu: 514.86M, memory: 0B, network: 0B}
         orderkey := orderkey:bigint:REGULAR

before:
trino> explain select count(orderkey) from hive.tpch_sf10_orc.lineitem;
                                            Query Plan
---------------------------------------------------------------------------------------------------
 Fragment 0 [SINGLE]
     Output layout: [count]
     Output partitioning: SINGLE []
     Output[columnNames = [_col0]]
     │   Layout: [count:bigint]
     │   Estimates: {rows: 1 (9B), cpu: 1.01G, memory: 9B, network: 514.86MB}
     │   _col0 := count
     └─ Aggregate[]
        │   Layout: [count:bigint]
        │   Estimates: {rows: 1 (9B), cpu: 1.01G, memory: 9B, network: 514.86MB}
        │   count := count("orderkey")
        └─ LocalExchange[partitioning = SINGLE]
           │   Layout: [orderkey:bigint]
           │   Estimates: {rows: 59986052 (514.86MB), cpu: 514.86M, memory: 0B, network: 514.86MB}
           └─ RemoteSource[sourceFragmentIds = [1]]
                  Layout: [orderkey:bigint]
                  Estimates:

 Fragment 1 [SOURCE]
     Output layout: [orderkey]
     Output partitioning: SINGLE []
     TableScan[table = hive:tpch_sf10_orc:lineitem]
         Layout: [orderkey:bigint]
         Estimates: {rows: 59986052 (514.86MB), cpu: 514.86M, memory: 0B, network: 0B}
         orderkey := orderkey:bigint:REGULAR
Previously:
 └─ Aggregate[type = PARTIAL, keys = [field], hash = [$hashvalue_3]]
    │   Layout: [field:integer, $hashvalue_3:bigint, count_2:bigint]
    │   Estimates:
    │   count_2 := count("field_0") (mask = expr)

Now:
 └─ Aggregate[type = PARTIAL, keys = [field], hash = [$hashvalue_3]]
    │   Layout: [field:integer, $hashvalue_3:bigint, count_2:bigint]
    │   count_2 := count("field_0") (mask = expr)
@sopel39 sopel39 force-pushed the ks/do_not_print_Estimates branch from d156bde to 59a645d Compare September 27, 2022 20:23
@sopel39 sopel39 merged commit 27def65 into trinodb:master Sep 28, 2022
@sopel39 sopel39 deleted the ks/do_not_print_Estimates branch September 28, 2022 09:31
@sopel39 sopel39 mentioned this pull request Sep 28, 2022
@github-actions github-actions bot added this to the 398 milestone Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants