From: | 狂奔的蜗牛 <1105066510(at)qq(dot)com> |
---|---|
To: | Tender Wang <tndrwang(at)gmail(dot)com> |
Cc: | pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>, aleksander <aleksander(at)timescale(dot)com> |
Subject: | 回复: BUG #18568: BUG: Result wrong when do group by on partition table! |
Date: | 2024-08-07 10:38:15 |
Message-ID: | tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
I readd RelabelType to branch in v5 patch, and add case to cover the code.
In new adding case: `SELECT c collate "C", count(c) FROM pagg_tab3 GROUP BY c collate "C" HAVING count(c) > 1 ORDER BY 1;`
According to original logic, group_by_has_partkey() will return false, it will lead to cannot do having filter in sub table, the result is correct but the performance is poor.
Our logic will get better performance.
About InvalidOid collation, non-character type's collation is 0(InvalidOid) always.
狂奔的蜗牛
1105066510(at)qq(dot)com
------------------ 原始邮件 ------------------
发件人: "Tender Wang" <tndrwang(at)gmail(dot)com>;
发送时间: 2024年8月7日(星期三) 下午5:23
收件人: "狂奔的蜗牛"<1105066510(at)qq(dot)com>;
抄送: "pgsql-bugs"<pgsql-bugs(at)lists(dot)postgresql(dot)org>;"aleksander"<aleksander(at)timescale(dot)com>;
主题: Re: BUG #18568: BUG: Result wrong when do group by on partition table!
狂奔的蜗牛 <1105066510(at)qq(dot)com> 于2024年8月7日周三 16:06写道:
PartCollMatchesExprColl() is not strict enough.
If partcoll == InvalidOid and groupcoll != InvalidOid, PartCollMatchesExprColl() return true always.
Just determine whether groupcoll is equal to partcoll, like this "partcoll == groupcoll".
I understand what you said. Actually, I keep it just curious when partcoll is InvalidOid. Why it works for partition prune.
Is it not same between check partkey is equal to groupexpr and check partkey is equal to qualclause?
We cannot delete "if (IsA(groupexpr, RelableTyple) " branch,
becasuse if groupexpr is RelabelType and partcoll equal to groupcoll, the "equal(groupexpr, partexpr) && PartKeyCollMatchesExprColl(partcoll, groupexpr_coll)" condition return false!!!
This is not what we expect.
" if groupexpr is RelabelType and partcoll equal to groupcoll ", according to original logic, will return false in this situation.
Now you think we can support above situation. Am I understand correctly?
We're better to add more test case to cover the code if we're going to support this. The test cases now seem not going
into the RelableTyple branch.
We could rename "groupexpr_coll" to groupcoll, it looks more elegant.
No objection. You can continue to support RelableType situation and add more test cases based on V4.
--
Tender Wang
Attachment | Content-Type | Size |
---|---|---|
v5-0001-fix-group_by_has_partkey-bug-and-add-regress-test.patch | application/octet-stream | 8.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Yeddula, Madhusudhan reddy [CONTINGENT WORKER] | 2024-08-07 11:14:38 | RE: BUG #18569: Memory leak in Postgres Enterprise server |
Previous Message | Tender Wang | 2024-08-07 09:23:21 | Re: BUG #18568: BUG: Result wrong when do group by on partition table! |