Re: Optimize join selectivity estimation by not reading MCV stats for unique join attributes
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: David Geier <geidav.pg@gmail.com>,
PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2022-11-18T01:36:50Z
Lists: pgsql-hackers
Attachments
- skip-reading-MCVs-when-only-one.patch (text/x-diff) patch
I wrote: > Tomas Vondra <tomas.vondra@enterprisedb.com> writes: >> Or perhaps what if we have a function that quickly determines if the >> attribute has MCV, without loading it? I'd bet the expensive part of >> get_attstatslot() is the deconstruct_array(). >> We could have a function that only does the first small loop over slots, >> and returns true/false if we have a slot of the requested stakind. > Yeah, I like this idea. Actually, looking at get_attstatslot, I realize it was already designed to do that -- just pass zero for flags. So we could do it as attached. We could make some consequent simplifications by only retaining one "have_mcvs" flag, but I'm inclined to leave the rest of the code as-is. We would not get much gain from that, and it would make this harder to undo if there ever is a reason to consider just one set of MCVs. regards, tom lane
Commits
-
Don't read MCV stats needlessly in eqjoinsel().
- f84ff0c6d4eb 16.0 landed