提交 ef39e0d0 编写于 作者: O Omer Arap

Fix incremental analyze for non-matching attnums

To merge stats in incremental analyze for root partition, we use leaf
tables' statistics. In commit b28d0297,
we fixed an issue where child attnum do not match with a root table's
attnum for the same column. After we fixed that issue with a test, that
test also exposed the bug in analyze code.

This commit fixes the issue in analyze using the similar fix in
b28d0297.
上级 f9dd6ba0
......@@ -3752,7 +3752,10 @@ merge_leaf_stats(VacAttrStatsP stats,
nullCount = nullCount +
get_attnullfrac(relid, stats->attr->attnum) * relTuples[i];
heaptupleStats[i] = get_att_stats(relid, stats->attr->attnum);
const char *attname = get_relid_attribute_name(stats->attr->attrelid, stats->attr->attnum);
AttrNumber child_attno = get_attnum(relid, attname);
heaptupleStats[i] = get_att_stats(relid, child_attno);
// if there is no colstats, we can skip this partition's stats
if (!HeapTupleIsValid(heaptupleStats[i]))
......
......@@ -1734,21 +1734,23 @@ ANALYZE dedup_test1;
ANALYZE dedup_test2;
ANALYZE dedup_test3;
EXPLAIN SELECT * FROM dedup_test1 INNER JOIN dedup_test2 ON dedup_test1.a= dedup_test2.e WHERE (a) IN (SELECT a FROM dedup_test3);
QUERY PLAN
-------------------------------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=3.31..5.46 rows=4 width=16)
-> Hash Semi Join (cost=3.31..5.46 rows=2 width=16)
Hash Cond: dedup_test1.a = subselect_gp.dedup_test3.a
-> Hash Join (cost=2.09..4.18 rows=2 width=16)
Hash Cond: dedup_test1.a = dedup_test2.e
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=3.24..5.37 rows=4 width=16)
-> Hash Join (cost=3.24..5.37 rows=2 width=16)
Hash Cond: dedup_test1.a = dedup_test2.e
-> Hash Join (cost=1.15..3.24 rows=2 width=12)
Hash Cond: dedup_test1.a = subselect_gp.dedup_test3.a
-> Seq Scan on dedup_test1 (cost=0.00..2.04 rows=2 width=8)
-> Hash (cost=2.04..2.04 rows=2 width=8)
-> Seq Scan on dedup_test2 (cost=0.00..2.04 rows=2 width=8)
-> Hash (cost=1.10..1.10 rows=4 width=4)
-> Append (cost=0.00..1.10 rows=4 width=4)
-> Seq Scan on dedup_test3_1_prt_1 dedup_test3 (cost=0.00..1.10 rows=4 width=4)
-> Hash (cost=1.14..1.14 rows=1 width=4)
-> HashAggregate (cost=1.12..1.14 rows=1 width=4)
Group Key: subselect_gp.dedup_test3.a
-> Append (cost=0.00..1.10 rows=4 width=4)
-> Seq Scan on dedup_test3_1_prt_1 dedup_test3 (cost=0.00..1.10 rows=4 width=4)
-> Hash (cost=2.04..2.04 rows=2 width=8)
-> Seq Scan on dedup_test2 (cost=0.00..2.04 rows=2 width=8)
Optimizer: legacy query optimizer
(12 rows)
(14 rows)
SELECT * FROM dedup_test1 INNER JOIN dedup_test2 ON dedup_test1.a= dedup_test2.e WHERE (a) IN (SELECT a FROM dedup_test3);
a | b | e | f
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册