From: Miloš Urbánek <milos.urbanek@email.cz>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17476: ERROR: "variable not found in subplan target list" when running SELECT COUNT(*)
Date: Mon, 09 May 2022 10:52:47 +0200 (CEST)
Message-ID: <61T.wBL}.7P5DeHGHwts.1YUDPV@scif.cz> (raw)
References: <17476-cf579fc6b204baa2@postgresql.org>
<3488097.1652055721@sss.pgh.pa.us>
<5wS.wBLd.2GdiEutIVdh.1YUC4K@scif.cz>
<CAFj8pRCmTZHid9CzwK55ehx33M5VcbY+b5sWDYwC844R27u76g@mail.gmail.com>
The problem occurs in test database restored from PG 14 backup. There are 2
tables (out of 900 other) where this problem occurs (when running SELECT
COUNT(*) on the table).
I can not look at the query plan because EXPLAIN fails aswell, but my guess
is that planner is trying to use index on the table to count the rows.
There are only 10 records in the table. When I run VACUUM FULL, the problem
disappears (planner is going to use Seq Scan which works).
The database schema for both tables is complex, there are 20+ columns, 3+
spatial data columns, 5 foreign keys, not such an easy task to create some
test case for you.
But my guess is that the root cause is planner trying to use index scan to
count the rows.
Therefore I hope that this is just another occurence of https://www.mail-
archive.com/postgis-users@lists.osgeo.org/msg09410.html.
Regards
--
Milosh
---------- Původní e-mail ----------
Od: Pavel Stehule <pavel.stehule@gmail.com>
Komu: Miloš Urbánek <milos.urbanek@email.cz>
Datum: 9. 5. 2022 10:22:16
Předmět: Re: BUG #17476: ERROR: "variable not found in subplan target list"
when running SELECT COUNT(*)
"
Hi
po 9. 5. 2022 v 9:22 odesílatel Miloš Urbánek <milos.urbanek@email.cz
(mailto:milos.urbanek@email.cz)> napsal:
"
I have 2 (ordinary) tables in 900+ table database restored from PG 9.6 (with
PostGIS geometries BTW) where this problem occurs.
The count() queries into the other tables are OK.
Also the problem happens only at the server but not at my Windows 10
workstation with the same PG 14.2.
"
Is there the same configuration on the server like on your workstation? The
different configuration can enforce a different execution plan.
Regards
Pavel
"
No clue what could be wrong.
PGAdmin4 fails even when trying to list SQL creation statement.
--
Milos Urbanek
---------- Původní e-mail ----------
Od: Tom Lane <tgl@sss.pgh.pa.us(mailto:tgl@sss.pgh.pa.us)>
Komu: milos.urbanek@email.cz(mailto:milos.urbanek@email.cz)
Datum: 9. 5. 2022 2:22:10
Předmět: Re: BUG #17476: ERROR: "variable not found in subplan target list"
when running SELECT COUNT(*)
"PG Bug reporting form <noreply@postgresql.org
(mailto:noreply@postgresql.org)> writes:
> Trying to run simple SELECT COUNT(*) from some table gives me the
following
> error (either running by hand or trying to run EXPLAIN using pgadmin or by
> hand):
> 2022-05-09 00:06:30.428 CEST [1196] ERROR: variable not found in subplan
> target list
> 2022-05-09 00:06:30.428 CEST [1196] STATEMENT: SELECT COUNT(*) FROM
> "domino_efekty_havarijniprojev"
Is that really just a table? I could believe a bug like this for
some types of views, but it's a bit hard to credit for a plain table.
In any case, we can't do much with this report unless you can provide
a reproducer case --- preferably a SQL script that creates an object
that triggers the problem.
regards, tom lane
"
"
"
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: milos.urbanek@email.cz, pavel.stehule@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: BUG #17476: ERROR: "variable not found in subplan target list" when running SELECT COUNT(*)
In-Reply-To: <61T.wBL}.7P5DeHGHwts.1YUDPV@scif.cz>
References: <17476-cf579fc6b204baa2@postgresql.org> <3488097.1652055721@sss.pgh.pa.us> <5wS.wBLd.2GdiEutIVdh.1YUC4K@scif.cz> <CAFj8pRCmTZHid9CzwK55ehx33M5VcbY+b5sWDYwC844R27u76g@mail.gmail.com> <61T.wBL}.7P5DeHGHwts.1YUDPV@scif.cz>
* 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