sql:
explain costs
SELECT
t1.group_id AS group_id,
t1.crowd_id AS crowd_id,
max(t1.crowd_name) AS crowd_name,
max(t1.group_name) AS group_name,
max(t1.dt) AS crowd_ct,
ifnull(sum(t2.cover_num), 0) AS cover_num,
ifnull(sum(t2.conv_num), 0) AS conv_num,
ifnull(sum(t2.conv_amt), 0) AS conv_amt
FROM
(
SELECT
group_id,
crowd_id,
max(crowd_name) AS crowd_name,
max(group_name) AS group_name,
max(dt) AS dt
FROM
ma_dc_custom_crowd
WHERE
job_id = ‘10000-33032’
AND target_id = ‘140’
AND job_version = ‘1’
AND group_id IN (‘ff187024-cd07-441b-9ba1-571da4940aee’)
AND tenant_id = 10000
GROUP BY
group_id,
crowd_id) t1
LEFT JOIN (
SELECT
group_id,
crowd_id,
cover_num,
conv_num,
conv_amt
FROM
ads_ma_crowd_statistics_1d
WHERE
dt = (
SELECT
max(dt)
FROM
ads_ma_crowd_statistics_1d
WHERE
tenant_id = 10000)
AND job_id = ‘10000-33032’
AND target_id = ‘140’
AND job_version = ‘1’
AND group_id IN (‘ff187024-cd07-441b-9ba1-571da4940aee’)
AND tenant_id = 10000) t2 ON
t1.group_id = t2.group_id
AND t1.crowd_id = t2.crowd_id
GROUP BY
t1.group_id,
t1.crowd_id;
—查询计划
PLAN FRAGMENT 0(F08)
Output Exprs:4: group_id | 5: crowd_id | 51: max | 52: max | 53: max | 57: ifnull | 58: ifnull | 59: ifnull
Input Partition: UNPARTITIONED
RESULT SINK
19:EXCHANGE
cardinality: 39
PLAN FRAGMENT 1(F07)
Input Partition: HASH_PARTITIONED: 4: group_id, 5: crowd_id
OutPut Partition: UNPARTITIONED
OutPut Exchange Id: 19
18:Project
| output columns:
| 4 <-> [4: group_id, VARCHAR, true]
| 5 <-> [5: crowd_id, VARCHAR, true]
| 51 <-> [51: max, VARCHAR, true]
| 52 <-> [52: max, VARCHAR, true]
| 53 <-> [53: max, DATE, true]
| 57 <-> ifnull[([54: sum, BIGINT, true], 0); args: BIGINT,BIGINT; result: BIGINT; args nullable: true; result nullable: true]
| 58 <-> ifnull[([55: sum, BIGINT, true], 0); args: BIGINT,BIGINT; result: BIGINT; args nullable: true; result nullable: true]
| 59 <-> ifnull[([56: sum, DECIMAL128(38,4), true], 0); args: DECIMAL128,DECIMAL128; result: DECIMAL128(38,4); args nullable: true; result nullable: true]
| hasNullableGenerateChild: true
| cardinality: 39
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * ifnull–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * ifnull–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * ifnull–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
17:AGGREGATE (update finalize)
| aggregate: max[([14: max, VARCHAR, true]); args: VARCHAR; result: VARCHAR; args nullable: true; result nullable: true], max[([15: max, VARCHAR, true]); args: VARCHAR; result: VARCHAR; args nullable: true; result nullable: true], max[([16: max, DATE, true]); args: DATE; result: DATE; args nullable: true; result nullable: true], sum[([28: cover_num, INT, true]); args: INT; result: BIGINT; args nullable: true; result nullable: true], sum[([29: conv_num, INT, true]); args: INT; result: BIGINT; args nullable: true; result nullable: true], sum[([30: conv_amt, DECIMAL64(18,4), true]); args: DECIMAL64; result: DECIMAL128(38,4); args nullable: true; result nullable: true]
| group by: [4: group_id, VARCHAR, true], [5: crowd_id, VARCHAR, true]
| hasNullableGenerateChild: true
| cardinality: 39
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * sum–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * sum–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * sum–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * ifnull–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * ifnull–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * ifnull–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
16:Project
| output columns:
| 4 <-> [4: group_id, VARCHAR, true]
| 5 <-> [5: crowd_id, VARCHAR, true]
| 14 <-> [14: max, VARCHAR, true]
| 15 <-> [15: max, VARCHAR, true]
| 16 <-> [16: max, DATE, true]
| 28 <-> [28: cover_num, INT, true]
| 29 <-> [29: conv_num, INT, true]
| 30 <-> [30: conv_amt, DECIMAL64(18,4), true]
| hasNullableGenerateChild: true
| cardinality: 74
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * cover_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_amt–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
15:HASH JOIN
| join op: LEFT OUTER JOIN (PARTITIONED)
| equal join conjunct: [4: group_id, VARCHAR, true] = [20: group_id, VARCHAR, true]
| equal join conjunct: [5: crowd_id, VARCHAR, true] = [21: crowd_id, VARCHAR, true]
| output columns: 4, 5, 14, 15, 16, 28, 29, 30
| cardinality: 74
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * cover_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_amt–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
|----14:EXCHANGE
| cardinality: 60
|
3:EXCHANGE
cardinality: 74
PLAN FRAGMENT 2(F02)
Input Partition: RANDOM
OutPut Partition: HASH_PARTITIONED: 20: group_id, 21: crowd_id
OutPut Exchange Id: 14
13:Project
| output columns:
| 20 <-> [20: group_id, VARCHAR, true]
| 21 <-> [21: crowd_id, VARCHAR, true]
| 28 <-> [28: cover_num, INT, true]
| 29 <-> [29: conv_num, INT, true]
| 30 <-> [30: conv_amt, DECIMAL64(18,4), true]
| cardinality: 60
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * cover_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_amt–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
12:HASH JOIN
| join op: INNER JOIN (BROADCAST)
| equal join conjunct: [22: dt, DATE, false] = [49: max, DATE, true]
| build runtime filters:
| - filter_id = 0, build_expr = (49: max), remote = false
| output columns: 20, 21, 28, 29, 30
| cardinality: 60
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * dt–>[1.6506432E9, 1.6546176E9, 0.0, 1.0, 1.0] UNKNOWN
| * cover_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_amt–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
|----11:EXCHANGE
| cardinality: 1
|
5:Project
| output columns:
| 20 <-> [20: group_id, VARCHAR, true]
| 21 <-> [21: crowd_id, VARCHAR, true]
| 22 <-> [22: dt, DATE, false]
| 28 <-> [28: cover_num, INT, true]
| 29 <-> [29: conv_num, INT, true]
| 30 <-> [30: conv_amt, DECIMAL64(18,4), true]
| cardinality: 60
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * dt–>[1.6506432E9, 1.6546176E9, 0.0, 1.0, 1.0] UNKNOWN
| * cover_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * conv_amt–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
4:OlapScanNode
table: ads_ma_crowd_statistics_1d, rollup: ads_ma_crowd_statistics_1d
preAggregation: on
Predicates: [17: job_id, VARCHAR, true] = ‘10000-33032’, [19: target_id, VARCHAR, true] = ‘140’, [18: job_version, VARCHAR, true] = ‘1’, [20: group_id, VARCHAR, true] = ‘ff187024-cd07-441b-9ba1-571da4940aee’, [24: tenant_id, INT, true] = 10000
partitionsRatio=29/189, tabletsRatio=29/87
tabletList=5990366,5990372,5990378,5990390,5990414,5990420,5990426,5990432,5990444,5990456 …
actualRows=31, avgRowSize=10.0
cardinality: 60
probe runtime filters:
- filter_id = 0, probe_expr = (22: dt)
column statistics:
* job_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* job_version–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* target_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* dt–>[1.6506432E9, 1.6546176E9, 0.0, 1.0, 1.0] UNKNOWN
* tenant_id–>[10000.0, 10000.0, 0.0, 1.0, 1.0] UNKNOWN
* cover_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* conv_num–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* conv_amt–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
PLAN FRAGMENT 3(F04)
Input Partition: UNPARTITIONED
OutPut Partition: UNPARTITIONED
OutPut Exchange Id: 11
10:AGGREGATE (merge finalize)
| aggregate: max[([49: max, DATE, true]); args: DATE; result: DATE; args nullable: true; result nullable: true]
| cardinality: 1
| column statistics:
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
9:EXCHANGE
cardinality: 1
PLAN FRAGMENT 4(F03)
Input Partition: RANDOM
OutPut Partition: UNPARTITIONED
OutPut Exchange Id: 09
8:AGGREGATE (update serialize)
| aggregate: max[([38: dt, DATE, false]); args: DATE; result: DATE; args nullable: false; result nullable: true]
| cardinality: 1
| column statistics:
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
7:Project
| output columns:
| 38 <-> [38: dt, DATE, false]
| cardinality: 60
| column statistics:
| * dt–>[1.6506432E9, 1.6546176E9, 0.0, 1.0, 1.0] UNKNOWN
|
6:OlapScanNode
table: ads_ma_crowd_statistics_1d, rollup: ads_ma_crowd_statistics_1d
preAggregation: on
Predicates: [40: tenant_id, INT, true] = 10000
partitionsRatio=29/189, tabletsRatio=87/87
tabletList=5990362,5990364,5990366,5990368,5990370,5990372,5990374,5990376,5990378,5990386 …
actualRows=119, avgRowSize=2.0
cardinality: 60
column statistics:
* dt–>[1.6506432E9, 1.6546176E9, 0.0, 1.0, 1.0] UNKNOWN
* tenant_id–>[10000.0, 10000.0, 0.0, 1.0, 1.0] UNKNOWN
PLAN FRAGMENT 5(F00)
Input Partition: RANDOM
OutPut Partition: HASH_PARTITIONED: 4: group_id, 5: crowd_id
OutPut Exchange Id: 03
2:AGGREGATE (update finalize)
| aggregate: max[([9: crowd_name, VARCHAR, true]); args: VARCHAR; result: VARCHAR; args nullable: true; result nullable: true], max[([11: group_name, VARCHAR, true]); args: VARCHAR; result: VARCHAR; args nullable: true; result nullable: true], max[([8: dt, DATE, false]); args: DATE; result: DATE; args nullable: false; result nullable: true]
| group by: [4: group_id, VARCHAR, true], [5: crowd_id, VARCHAR, true]
| cardinality: 74
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * max–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
1:Project
| output columns:
| 4 <-> [4: group_id, VARCHAR, true]
| 5 <-> [5: crowd_id, VARCHAR, true]
| 8 <-> [8: dt, DATE, false]
| 9 <-> [9: crowd_name, VARCHAR, true]
| 11 <-> [11: group_name, VARCHAR, true]
| cardinality: 141
| column statistics:
| * group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * dt–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * crowd_name–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
| * group_name–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
|
0:OlapScanNode
table: ma_dc_custom_crowd, rollup: ma_dc_custom_crowd
preAggregation: on
Predicates: [1: job_id, VARCHAR, true] = ‘10000-33032’, [3: target_id, VARCHAR, true] = ‘140’, [2: job_version, VARCHAR, true] = ‘1’, [4: group_id, VARCHAR, true] = ‘ff187024-cd07-441b-9ba1-571da4940aee’, [13: tenant_id, INT, true] = 10000
partitionsRatio=1/1, tabletsRatio=1/3
tabletList=39639
actualRows=99, avgRowSize=9.0
cardinality: 141
column statistics:
* job_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* job_version–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* target_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* group_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* crowd_id–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* dt–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* crowd_name–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* group_name–>[-Infinity, Infinity, 0.0, 1.0, 1.0] UNKNOWN
* tenant_id–>[10000.0, 10000.0, 0.0, 1.0, 1.0] UNKNOWN