Skip to content

[PATCH] create_range_partitions large distance between DATE or TIMESTAMP values #208

@GuramDuka

Description

@GuramDuka

postgresql 11.5, pathman 1.5

If there is a large distance between the values ​​in the table, a lot of partitions are created, which is why the operation may never be completed (if the number of partitions exceeds 1000).
For example, in the table there are two records of the field by which the table is ranged with the values ​​2010-01-01 and 3999-12-01 and the month interval is set.
SELECT create_range_partitions (relid, '_period', '1 mon' :: interval);
I propose a patch that solves the problem by creating partitions only for which there are values ​​in the table, and then, when automatically creating partitions, only those are created for which the value in the record falls into the interval.

При наличии в таблице большого разрыва между значениями создается очень много партиций, отчего операция может не завершится никогда (если количество партиций превышает 1000).
Например в таблице две записи поля по которому ранжируется таблица со значениями 2010-01-01 и 3999-12-01 и задается интервал например месяц или ещё меньше.
SELECT create_range_partitions(relid, '_period', '1 mon'::interval);
Предлагаю патч который решает проблему путем создания партиций только тех для которых есть значения в таблице и далее при автоматическом создании партиций создаются только те для которых значение в записи попало в интервал.

postgresql-pg_pathman_.patch.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions