pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dmitry Dolgov <9erthalion6@gmail.com>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: Tomas Vondra <tomas.vondra@postgresql.org>
Cc: Manuel Rigger <rigger.manuel@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: Failed assertion clauses != NIL
Date: Tue, 19 Nov 2019 15:38:42 +0100
Message-ID: <20191119143842.s2rrzdg43pvw3ael@localhost> (raw)
In-Reply-To: <520C6E76-53A5-4EF2-A855-8054582221A5@yesql.se>
References: <CA+u7OA7H5rcE2=8f263w4NZD6ipO_XOrYB816nuLXbmSTH9pQQ@mail.gmail.com>
	<20191119133839.5qj5zia4pkd3zldt@localhost>
	<520C6E76-53A5-4EF2-A855-8054582221A5@yesql.se>

> On Tue, Nov 19, 2019 at 02:45:54PM +0100, Daniel Gustafsson wrote:
> > On 19 Nov 2019, at 14:38, Dmitry Dolgov <9erthalion6@gmail.com> wrote:
> >
> >> On Tue, Nov 19, 2019 at 01:50:51PM +0100, Manuel Rigger wrote:
> >>
> >> when building PostgreSQL with -enable-cassert, executing the following
> >> statements result in an assertion error:
> >>
> >> CREATE TABLE t0(c0 boolean, c1 boolean, c2 boolean);
> >> INSERT INTO t0 VALUES(FALSE, FALSE, FALSE);
> >> CREATE STATISTICS s0 ON c0, c2 FROM t0;
> >> ANALYZE;
> >> SELECT * FROM t0 WHERE t0.c2 OR t0.c1 OR t0.c0;
> >
> > Yes, I can reproduce it too. mcv_get_match_bitmap expects that
> > stat_clauses will not be empty, but looks like in this situation
> > stat_clauses is indeed NIL. clauselist_selectivity_simple right before
> > actually doesn't insist on stat_clauses being non empty, probably it's
> > just too strict assert.
>
> I might be missing something, but if the clause list is NIL, wouldn't it better
> to exit earlier from statext_mcv_clauselist_selectivity rather than relax the
> Assertion since we will get a 1.0 estimate either way?
>
> cheers ./daniel
>
> --- a/src/backend/statistics/extended_stats.c
> +++ b/src/backend/statistics/extended_stats.c
> @@ -1267,6 +1267,9 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli
>                 listidx++;
>         }
>
> +       if (stat_clauses == NIL)
> +               return 1.0;
> +
>         /*
>          * First compute "simple" selectivity, i.e. without the extended
>          * statistics, and essentially assuming independence of the
>

Yep, seems like a reasonable thing to do, especially since it's already
like that in a few other places in this function.





view thread (13+ messages)  latest in thread

Message-ID: <20191119143842.s2rrzdg43pvw3ael@localhost>
Permalink:  ../20191119143842.s2rrzdg43pvw3ael@localhost/
Also on:    postgresql.org/message-id/20191119143842.s2rrzdg43pvw3ael@localhost

 · 

reply

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-bugs@postgresql.org
  Cc: 9erthalion6@gmail.com, daniel@yesql.se, tomas.vondra@postgresql.org, rigger.manuel@gmail.com
  Subject: Re: Failed assertion clauses != NIL
  In-Reply-To: <20191119143842.s2rrzdg43pvw3ael@localhost>
  References: <CA+u7OA7H5rcE2=8f263w4NZD6ipO_XOrYB816nuLXbmSTH9pQQ@mail.gmail.com> <20191119133839.5qj5zia4pkd3zldt@localhost> <520C6E76-53A5-4EF2-A855-8054582221A5@yesql.se> <20191119143842.s2rrzdg43pvw3ael@localhost>

* 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