Re: BUG #14948: cost overflow

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jasc(at)gmx(dot)net
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14948: cost overflow
Date: 2017-12-05 15:10:20
Message-ID: 28067.1512486620@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

jasc(at)gmx(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bossart, Nathan 2017-12-05 16:52:40 Re: BUG #14941: Vacuum crashes
Previous Message Alvaro Herrera 2017-12-05 12:39:29 Re: BUG #14948: cost overflow