Re: [PATCH] ANALYZE: hash-accelerate MCV tracking for equality-only types
Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
From: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
To: Chengpeng Yan <chengpeng_yan@Outlook.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>,
John Naylor <johncnaylorls@gmail.com>
Date: 2026-01-29T21:54:15Z
Lists: pgsql-hackers
On 22.01.2026 12:40, Chengpeng Yan wrote: > The v2 patch is attached. I took a deeper look at the v2 patch. The hash-based lookup itself looks correct, and when testing ANALYZE runtime with large default_statistics_target values, the patch indeed provides a noticeable speedup. I have one small suggestion regarding the handling of firstcount1 and c1_cursor in the 'match' path. When we find a match in track[], we increment count and perform bubble-up swaps to keep the array ordered by frequency. If the value previously has count = 1, it is effectively leaving the singleton (count = 1) region and becoming part of the count>1. Conceptually, this means that the boundary between these two regions (firstcount1) should move left by one. Given that, it seems sufficient to update the boundary and then ensure that c1_cursor still point inside the singleton region: if (was_count1 && j < firstcount1) firstcount1--; if (c1_cursor < firstcount1) c1_cursor = firstcount1; This avoids reasoning about specific shifted subranges (firstcount1..match_index). FIFO behavior is still preserved because c1_cursor is only advanced when an eviction actually happens. Let me know if I'm overlooking any corner cases. -- Best regards. Ilia Evdokimov, Tantor Labs LLC, https://tantorlabs.com/
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Speed up eqjoinsel() with lots of MCV entries.
- 057012b205a0 19 (unreleased) cited