If I insert a row to partitioned table which is in local, a partitioned table’s constraints should work. If I add a constraint on a partitioned table, I should be make sure I can not insert a row which is out of partitioned table’s constraints. But I could. I think, partitioned table’s constraints should work with regard to environment. If I work on local, constraints work for local tables and should not consider other environment’s constraints.
To be more clear, I would like to add EXPLAIN ANALYZE script.
artemis=# explain (analyze,verbose) insert into students values(2,'another name'); QUERY PLAN
-------------------------------------------------------------------------------------- ------------------ Insert on public.students (cost=0.00..0.01 rows=1 width=36) (actual time=1.536..1.53 9 rows=0 loops=1) Remote SQL: INSERT INTO public.students(id, name) VALUES ($1, $2) -> Result (cost=0.00..0.01 rows=1 width=36) (actual time=0.005..0.013 rows=1 loop s=1) Output: 2, 'another name'::character varying Planning time: 0.063 ms Execution time: 2.877 ms (6 rows)
We use push-down for INSERT statement but I think constraints should be checked before sending SQL statements then INSERT statements should be perform.
If it's nature, why do we require to add unused constraint for FDW side only?