pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jasc@gmx.net
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14948: cost overflow
Date: Tue, 05 Dec 2017 10:10:20 -0500
Message-ID: <28067.1512486620@sss.pgh.pa.us> (raw)
In-Reply-To: <20171205105924.27108.93509@wrigleys.postgresql.org>
References: <20171205105924.27108.93509@wrigleys.postgresql.org>

jasc@gmx.net writes:
> We have a server which reports negative costs in a query plan:

The root of the weirdness seems to be here:

>           ->  Bitmap Heap Scan on converting_touchpoints_attribution conv (cost=-2021924572970281.75..-2021924572970244.00 rows=1 width=10) (never executed)
>                 Recheck Cond: ((t.touchpoint_id = touchpoint_fk) AND (performance_attribution_model_fk = 2))
>                 ->  BitmapAnd (cost=-2021924572970281.75..-2021924572970281.75 rows=1850 width=0) (never executed)
>                       ->  Bitmap Index Scan on converting_touchpoints_attribution__touchpoint_fk (cost=0.00..-2021911688068401.00 rows=1850 width=0) (never executed)
>                             Index Cond: (t.touchpoint_id = touchpoint_fk)
>                       ->  Bitmap Index Scan on converting_touchpoints_attribution__performance_attribution_mod (cost=0.00..-12884901880.97 rows=1850 width=0) (never executed)
>                             Index Cond: (performance_attribution_model_fk = 2)

I'm not sure what to make of that, but it seems to be broken in more ways
than just the wacko cost estimates.  For one thing, the planner is supposed
to set up index qual conditions in the form "indexedvar op something",
and the (t.touchpoint_id = touchpoint_fk) condition appears to be
backwards.  The row estimate at the intermediate BitmapAnd node seems
to be out of line as well, why doesn't it match the estimate for the
heapscan node?

Can you get a similarly broken plan if you try something involving just
this table, say "select * from converting_touchpoints_attribution where
touchpoint_fk = 42 and performance_attribution_model_fk = 2" ?

Could we see the pg_stats rows for those two columns?  What is in
pg_class.reltuples and relpages for this table and these two indexes?

			regards, tom lane




view thread (11+ messages)  latest in thread

Message-ID: <28067.1512486620@sss.pgh.pa.us>
Permalink:  ../28067.1512486620@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28067.1512486620@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, jasc@gmx.net
  Subject: Re: BUG #14948: cost overflow
  In-Reply-To: <28067.1512486620@sss.pgh.pa.us>
  References: <20171205105924.27108.93509@wrigleys.postgresql.org> <28067.1512486620@sss.pgh.pa.us>

* 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