| From: | Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | ExplainModifyTarget doesn't work as expected |
| Date: | 2014-12-22 06:50:52 |
| Message-ID: | 5497BF4C.6080302@lab.ntt.co.jp |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 | Content-Type | Size |
|---|---|---|
| explain-inherited-updates.patch | text/x-patch | 5.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2014-12-22 07:24:52 | Commit Fest 2014-12, Status after week 1 |
| Previous Message | Tatsuo Ishii | 2014-12-22 06:36:36 | Re: pgbench -f and vacuum |