| From: | ZizhuanLiu X-MAN <44973863(at)qq(dot)com> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | jian he <jian(dot)universality(at)gmail(dot)com>, tgl <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Guo <rguo(at)postgresql(dot)org> |
| Subject: | Re: examine_variable ignored CollateExpr |
| Date: | 2026-10-12 13:22:35 |
| Message-ID: | tencent_1CE0A7DAF468F52662BF752CA1A8771A3909@qq.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
>Original
>From: shihao zhong <zhong950419(at)gmail(dot)com>
>Date: 2026-10-11 10:38
>To: ZizhuanLiu X-MAN <44973863(at)qq(dot)com>
>Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>, tgl <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Guo <rguo(at)postgresql(dot)org>
>Subject: Re: examine_variable ignored CollateExpr
>
>Hi Zizhuan,
>
>Thanks for v5. My example is fixed, I get rows=100 again. The
>regression tests pass, and I could not measure any change in
>planning time for varchar columns.
>
>One more issue
>
> CREATE TABLE t (a text);
> INSERT INTO t SELECT chr(65 + g % 52) || g
> FROM generate_series(1, 5200) g;
> CREATE STATISTICS s ON (left(a, 1) COLLATE "C") FROM t;
> ANALYZE t;
> EXPLAIN SELECT * FROM t WHERE left(a, 1) = 'A';
>
>On master I get rows=100, with v5 I get rows=26. I think the retry
>only runs when the query has the COLLATE, not when only the
>statistics expression has it.
>
>v5 also dropped the tests that v1 had. Could you add them back,
>with this case and my earlier one?
>
>Thanks,
>Shihao
Hi, Shihao,hackers
Thank you for your prompt and constructive feedback.
I've updated the code to avoid unnecessary comparisons on retry.
It now separately tracks whether node, indexpr, and statexpr have
a topmost RelabelType associated with COLLATE, and uses these
flags to determine which comparisons are necessary:
- indexpr is compared only if basenode_is_topmost_relabeltype or indexkey_is_topmost_relabeltype is true.
- statexpr is compared only if basenode_is_topmost_relabeltype or statexpr_is_topmost_relabeltype is true.
All the issues you mentioned have been addressed, and the missing test cases have been added.
The corresponding regression tests and expected output have also been updated in the .sql and .out files.
Thanks again for your review and suggestions.
regards,
--
ZizhuanLiu (X-MAN)
44973863(at)qq(dot)com
| Attachment | Content-Type | Size |
|---|---|---|
| v6-0001-Fix-RelabelType-handling-in-statistics-lookup.patch | application/octet-stream | 30.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2026-10-12 13:45:11 | Re: [PATCH] pg_upgrade: add --initdb option to create the new cluster automatically |
| Previous Message | Ayush Tiwari | 2026-10-12 13:09:56 | Re: PANIC serves too many masters |