ExplainModifyTarget doesn't work as expected - Mailing list pgsql-hackers

From Etsuro Fujita
Subject ExplainModifyTarget doesn't work as expected
Date
Msg-id 5497BF4C.6080302@lab.ntt.co.jp
Whole thread Raw
Responses Re: ExplainModifyTarget doesn't work as expected  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Re: ExplainModifyTarget doesn't work as expected  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
List pgsql-hackers
Hi,

I think ExplainModifyTarget should show the parent of the inheritance
tree in multi-target-table cases, as described there, but noticed that
it doesn't always work like that.  Here is an example.

postgres=# create table parent (a int check (a < 0) no inherit);
CREATE TABLE
postgres=# create table child (a int check (a >= 0));
CREATE TABLE
postgres=# alter table child inherit parent;
ALTER TABLE
postgres=# explain update parent set a = a * 2 where a >= 0;
                          QUERY PLAN
---------------------------------------------------------------
 Update on child  (cost=0.00..42.00 rows=800 width=10)
   ->  Seq Scan on child  (cost=0.00..42.00 rows=800 width=10)
         Filter: (a >= 0)
(3 rows)

IIUC, I think this is because ExplainModifyTarget doesn't take into
account that the parent *can* be excluded by constraint exclusion.  So,
I added a field to ModifyTable to record the parent, apart from
resultRelations.  (More precisely, the parent in its role as a simple
member of the inheritance tree is recorded so that appending digits to
refname in select_rtable_names_for_explain works as before.)  Attached
is a proposed patch for that.

Thanks,

Best regards,
Etsuro Fujita

Attachment

pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: pgbench -f and vacuum
Next
From: Michael Paquier
Date:
Subject: Commit Fest 2014-12, Status after week 1