Re: Sudden database error with COUNT(*) making Query Planner crashes: variable not found in subplan target list

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Jean Landercy - BEEODIVERSITY <jean(dot)landercy(at)beeodiversity(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Sudden database error with COUNT(*) making Query Planner crashes: variable not found in subplan target list
Date: 2022-06-07 21:24:06
Message-ID: 1339803.1654637046@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> That ... is pretty quirky already. How did it prefer a scan with cost
> 19.32 over one with cost 9.39? Seems like we've got a bug here somewhere.
> The change in estimated rowcount is rather broken, too.

Ah, false alarm. I can reproduce your results if I stick an ANALYZE
between the first and second EXPLAIN. So probably your change in
estimated rowcount and hence cost can be explained by an auto-analyze
coming along at just the right time.

Also, if I fill the geom and location columns with non-null data,
the planner stops preferring those indexes.

So now I'm guessing that the OP's data *was* mostly null, and the
planner preferred the gist indexes because they were smallest,
and then tripped over the nonreturnable-column bug.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2022-06-07 21:38:03 Re: Collation version tracking for macOS
Previous Message Jacob Champion 2022-06-07 21:22:28 Re: [PoC] Let libpq reject unexpected authentication requests