| From: | zengxx <xiangxin_zeng(at)qq(dot)com> |
|---|---|
| To: | Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Improve Hash/Merge Join estimate accuracy when all predicates are Hash/Merge clauses |
| Date: | 2026-10-14 00:53:26 |
| Message-ID: | tencent_BCBE9B4D2895C83674CF7C343A11B7AC1208@qq.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Ilia,
Thanks for the v4.
I rebuilt it and found a simple case where 0001 can be less accurate than master.
CREATE TABLE p(k int PRIMARY KEY);
CREATE TABLE f(id int PRIMARY KEY, k int REFERENCES p(k), aux int);
INSERT INTO p SELECT i FROM generate_series(1, 10000) i;
INSERT INTO f SELECT i, i, 1 FROM generate_series(1, 10000) i;
INSERT INTO f SELECT 10000 + i, NULL, 2 FROM generate_series(1, 10000) i;
ANALYZE p;
ANALYZE f;
SET enable_hashjoin = off;
SET enable_nestloop = off;
EXPLAIN (COSTS ON)
SELECT count(*) FROM f JOIN p ON f.k = p.k WHERE f.aux = 1;
SELECT count(*) FROM f JOIN p ON f.k = p.k WHERE f.aux = 1;
The global nullfrac for f.k is 0.5, but after f.aux = 1 all remaining rows have non-NULL f.k. Master estimates 10000 rows, matching the actual result. v4 estimates 5000.
So using the global stanullfrac can still be inaccurate when NULLs are correlated with filters on other columns. I am not sure what the right fix should be: conditional nullfrac, extended statistics, or just documenting the limitation. I'd appreciate feedback from people more familiar with selfuncs.
For 0002, I do not have a new semantic counterexample. The JOIN_INNER and equal-list-length restriction still looks reasonable to me.
I would especially appreciate feedback from people more familiar with selfuncs and cost estimate.
Xiangxin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Min, Baohong | 2026-10-14 01:05:00 | RE: [PATCH] Reduce LWLockWaitListLock() cache-line contention with adaptive spin reads |
| Previous Message | surya poondla | 2026-10-14 00:38:59 | Re: WAL_LOG CREATE DATABASE strategy broken for non-standard page layouts |