pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Killing off removed rels properly
Date: Mon, 20 Feb 2023 11:53:43 -0500
Message-ID: <3587195.1676912023@sss.pgh.pa.us> (raw)
In-Reply-To: <3582657.1676910808@sss.pgh.pa.us>
References: <229905.1676062220@sss.pgh.pa.us>
	<CAMbWs4_zhe22XqurMdcTx0PpSovHnCJSii3LXiutF_Hpdb9bxg@mail.gmail.com>
	<1343881.1676313553@sss.pgh.pa.us>
	<36bee393-b351-16ac-93b2-d46d83637e45@gmail.com>
	<3582657.1676910808@sss.pgh.pa.us>

Hmm, there's something else going on here.  After getting rid of the
assertion failure, I see that the plan looks like

# explain MERGE INTO tt USING st ON tt.tid = st.sid WHEN NOT MATCHED THEN INSERT 
VALUES (st.sid);
                         QUERY PLAN                          
-------------------------------------------------------------
 Merge on tt  (cost=0.00..35.50 rows=0 width=0)
   ->  Seq Scan on st  (cost=0.00..35.50 rows=2550 width=10)
(2 rows)

which is fairly nonsensical and doesn't match v15's plan:

 Merge on tt  (cost=0.15..544.88 rows=0 width=0)
   Merge on ttp tt_1
   ->  Nested Loop Left Join  (cost=0.15..544.88 rows=32512 width=14)
         ->  Seq Scan on st  (cost=0.00..35.50 rows=2550 width=4)
         ->  Index Scan using ttp_pkey on ttp tt_1  (cost=0.15..0.19 rows=1 widt
h=14)
               Index Cond: (tid = st.sid)

It looks like we're somehow triggering the elide-a-left-join code
when we shouldn't?  That explains why the target table's RelOptInfo
has gone missing and broken make_modifytable's expectations.
That code is still unnecessarily fragile so I intend to rearrange it,
but there's more to do here.

			regards, tom lane





view thread (9+ messages)  latest in thread

Message-ID: <3587195.1676912023@sss.pgh.pa.us>
Permalink:  ../3587195.1676912023@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3587195.1676912023@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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, exclusion@gmail.com, guofenglinux@gmail.com
  Subject: Re: Killing off removed rels properly
  In-Reply-To: <3587195.1676912023@sss.pgh.pa.us>
  References: <229905.1676062220@sss.pgh.pa.us> <CAMbWs4_zhe22XqurMdcTx0PpSovHnCJSii3LXiutF_Hpdb9bxg@mail.gmail.com> <1343881.1676313553@sss.pgh.pa.us> <36bee393-b351-16ac-93b2-d46d83637e45@gmail.com> <3582657.1676910808@sss.pgh.pa.us> <3587195.1676912023@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