-
Notifications
You must be signed in to change notification settings - Fork 67
How do I create indexes?
Ildar Musin edited this page Aug 26, 2017
·
3 revisions
If you haven't created partitions yet, then create index on parent before calling create_range_partitions()
or create_hash_partitions()
. The index will be automatically propagated for each partition as new partitions created.
If you want to create index on existing partitions use this snippet (don't forget to change table and key attribute names to actual names):
do
$$
declare
rec record;
begin
for rec in select * from pathman_partition_list where parent = 'table_name'::regclass
loop
execute format('create index on %s (attr_name)', rec.partition);
end loop;
end
$$
language plpgsql;