test2.sql

text/plain

Filename: test2.sql
Type: text/plain
Part: 1
Message: Re: Partitioning option for COPY
set copy_partitioning_cache_size = 0;

drop table parent cascade;

create table parent(i int, j int);
create table c1 (check (i > 0 and i <= 1)) inherits (parent);
create table c2 (check (i > 1 and i <= 2)) inherits (parent);
create table c3 (check (i > 2 and i <= 3)) inherits (parent);

create index c1_idx on c1(j);

copy (select i % 3 + 1, i from generate_series(1, 1000) s(i)) to '/tmp/parent';

copy parent from '/tmp/parent' with (partitioning);

analyse;

set enable_seqscan to false;
-- no rows, index was not updated
select * from c1 where j = 3;

set enable_seqscan to true;
set enable_indexscan to false;
-- some rows
select * from c1 where j = 3;