From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Alexander Lakhin <exclusion(at)gmail(dot)com>, Jian Guo <gjian(at)vmware(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Hans Buschmann <buschmann(at)nidsa(dot)net>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Zhenghua Lyu <zlyu(at)vmware(dot)com> |
Subject: | Re: Wrong rows estimations with joins of CTEs slows queries by more than factor 500 |
Date: | 2024-01-08 11:14:11 |
Message-ID: | CAMbWs49cnL7OcSfiyJ_VEKSYE1L5X7KjhOtVzSmkSauE89pLPQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Jan 7, 2024 at 6:41 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
> > Please look at the following query:
> > CREATE TABLE t(i int);
> > INSERT INTO t VALUES (1);
> > VACUUM ANALYZE t;
>
> > WITH ir AS (INSERT INTO t VALUES (2) RETURNING i)
> > SELECT * FROM ir WHERE i = 2;
>
> > which produces ERROR: no relation entry for relid 1
> > starting from f7816aec2.
Nice catch.
> Thanks for the report! I guess we need something like the attached.
+1.
> I'm surprised that this hasn't been noticed before; was the case
> really unreachable before?
It seems that this case is only reachable with Vars of an INSERT target
relation, and it seems that there is no other way to reference such a
Var other than using CTE.
Thanks
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | David Geier | 2024-01-08 11:21:24 | Re: postgres_fdw fails to see that array type belongs to extension |
Previous Message | Geoff Winkless | 2024-01-08 11:12:43 | Re: weird GROUPING SETS and ORDER BY behaviour |