Re: Declarative partitioning - another take

From: Dmitry Ivanov <d(dot)ivanov(at)postgrespro(dot)ru>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Dmitry Ivanov <d(dot)ivanov(at)postgrespro(dot)ru>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Erik Rijkers <er(at)xs4all(dot)nl>, Amit Langote <amitlangote09(at)gmail(dot)com>, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, <pgsql-hackers-owner(at)postgresql(dot)org>
Subject: Re: Declarative partitioning - another take
Date: 2016-12-15 15:40:11
Message-ID: b9d98afc-d8fe-4221-bf4d-e8e791a93e0c@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi everyone,

Looks like "sql_inheritance" GUC is affecting partitioned tables:

explain (costs off) select * from test;
QUERY PLAN
------------------------------
Append
-> Seq Scan on test
-> Seq Scan on test_1
-> Seq Scan on test_2
-> Seq Scan on test_1_1
-> Seq Scan on test_1_2
-> Seq Scan on test_1_1_1
-> Seq Scan on test_1_2_1
(8 rows)

set sql_inheritance = off;

explain (costs off) select * from test;
QUERY PLAN
------------------
Seq Scan on test
(1 row)

I might be wrong, but IMO this should not happen. Queries involving update,
delete etc on partitioned tables are basically broken. Moreover, there's no
point in performing such operations on a parent table that's supposed to be
empty at all times.

I've come up with a patch which fixes this behavior for UPDATE, DELETE,
TRUNCATE and also in transformTableEntry(). It might be hacky, but it gives
an idea.

I didn't touch RenameConstraint() and renameatt() since this would break
ALTER TABLE ONLY command.

--
Dmitry Ivanov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

Attachment Content-Type Size
partitioning_inh_flag_v1.diff text/x-patch 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2016-12-15 15:45:11 Re: Missing newlines in error messages
Previous Message Tom Lane 2016-12-15 15:38:55 Re: Missing newlines in error messages