From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Extended statistics on expressions
Date: Wed, 31 Mar 2021 19:54:11 +0200
Message-ID: <eae26b31-2d9b-1293-a3b0-a8be4820bea3@enterprisedb.com> (raw)
In-Reply-To: <20210331170828.GA26795@alvherre.pgsql>
References: <20210331170828.GA26795@alvherre.pgsql>
On 3/31/21 7:08 PM, Alvaro Herrera wrote:
> On 2021-Mar-31, Tomas Vondra wrote:
>
>> Thanks for the report, I'll take a look. You're right this seems like an
>> out-of-bounds access, but mcv_match_expression is only expected to be
>> run on expressions we know are in the statistics (because we pick the
>> statistics like that). Clearly, that does not happen here, not sure why.
>>
>> It's quite weird that we end up running textlike(), when the statistics
>> is on (double precision, boolean) columns ...
>
> Uninitialized values somewhere? Maybe valgrind would help.
>
Unlikely, I've ran it through valgrind repeatedly, including right
before commit (both on x86_64 and arm).
FWIW I'm unable to reproduce it, so not sure what's going on. David,
what configure option are you using? Anything special?
It's a bit strange, because statext_mcv_clauselist_selectivity should
only estimate "matching" clauses on the statistics. So how come this
estimates such a complex expression using textlike(), when neither of
those columns is text?
It'd be interesting to know what's happening in the code after
stat = choose_best_statistics(...);
i.e. what clauses it considers "compatible" with the statistics and why.
In fact, I wouldn't have expected the statistics to be used at all.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tomas.vondra@enterprisedb.com, alvherre@alvh.no-ip.org
Subject: Re: pgsql: Extended statistics on expressions
In-Reply-To: <eae26b31-2d9b-1293-a3b0-a8be4820bea3@enterprisedb.com>
References: <20210331170828.GA26795@alvherre.pgsql> <eae26b31-2d9b-1293-a3b0-a8be4820bea3@enterprisedb.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox