{"id":408089,"date":"2024-06-29T19:57:01","date_gmt":"2024-06-29T19:57:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=408089"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=408089","title":{"rendered":"<span>\u041f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 Greenplum 7: \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Greenplum 7 \u2014 \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0421\u0423\u0411\u0414, \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430\u044f \u0441 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0438\u0437 PostgreSQL: World DB.\u00a0<\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f: \u0434\u043e PostgreSQL 10 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 PostgreSQL \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u043e\u0441\u044c \u0432 \u043e\u0447\u0435\u043d\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0438 \u043f\u043e \u0441\u0443\u0442\u0438, \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 PostgreSQL 10, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432.\u00a0<\/p>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u043b\u0438\u044f\u043d\u0438\u044f \u0441 PostgreSQL 12 Greenplum 7 \u0432\u043e\u0431\u0440\u0430\u043b \u0432 \u0441\u0435\u0431\u044f \u0432\u0435\u0441\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 PostgreSQL \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 Greenplum. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 Greenplum 7 \u0435\u0441\u0442\u044c \u0448\u0430\u043d\u0441 \u0432\u0437\u044f\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0435 \u0438\u0437 \u043e\u0431\u043e\u0438\u0445 \u043c\u0438\u0440\u043e\u0432 \u2014 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e, \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/928\/db0\/c17\/928db0c17030e7b2b85a09c563d81fea.png\" width=\"2096\" height=\"1598\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/928\/db0\/c17\/928db0c17030e7b2b85a09c563d81fea.png\"\/><\/figure>\n<h3>\u041d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043d\u0430\u0447\u043d\u0451\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0432 Greenplum 7, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.\u00a0<\/p>\n<p>PostgreSQL \u0438\u043c\u0435\u0435\u0442 \u0442\u043e \u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0438 Greenplum, \u2014 <code>PARTITION BY<\/code>. \u041e\u043d\u043e \u0436\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 Greenplum 7. \u0422\u0430\u043a\u0436\u0435 \u0443 PostgreSQL \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f <code>RANGE<\/code> \u0438 <code>LIST<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Greenplum \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0432 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438. \u041d\u043e \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435: Greenplum 7 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0435\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date);<\/code><\/pre>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code>CREATE TABLE ... PARTITION BY<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432. \u0414\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u0432 Greenplum 7 \u2014 \u044d\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 (\u0438\u0445 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445).\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/206\/691\/0ad\/2066910ad2a7f753101dcc8cbcc832e9.jpg\" alt=\"\" title=\"\" width=\"780\" height=\"100\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/206\/691\/0ad\/2066910ad2a7f753101dcc8cbcc832e9.jpg\" data-blurred=\"true\"\/><\/figure>\n<p><a href=\"https:\/\/slurm.io\/green-plum?utm_source=habr&amp;utm_medium=promo&amp;utm_campaign=green-plum&amp;utm_content=promo_31-03-2023&amp;utm_term=gornushkina\"><u>\u00abDWH\u00a0\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435\u00a0GreenPlum\u00bb<\/u><\/a><\/p>\n<h3>\u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0445\u0435\u0448\u0430<\/h3>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>RANGE<\/code> \u0438 <code>LIST<\/code> Greenplum 7 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <code>HASH<\/code>. \u042d\u0442\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 PostgreSQL. \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u044d\u0448-\u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0435\u0451 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432:<\/p>\n<pre><code>-- create a tabled partitioned by hash strategy CREATE TABLE sales_by_hour (id int, date date, hour int, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY HASH (hour);  -- every hash partition modulus must be a factor of the next larger modulus CREATE TABLE sales_by_hour_1 PARTITION OF sales_by_hour FOR VALUES WITH (MODULUS 24, REMAINDER 0); CREATE TABLE sales_by_hour_2 PARTITION OF sales_by_hour FOR VALUES WITH (MODULUS 24, REMAINDER 1); CREATE TABLE sales_by_hour_3 PARTITION OF sales_by_hour FOR VALUES WITH (MODULUS 24, REMAINDER 2); ......<\/code><\/pre>\n<h4>\u041d\u043e\u0432\u044b\u0439 DDL<\/h4>\n<p>\u041e\u0431\u0441\u0443\u0434\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f Greenplum 7, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 DDL.<\/p>\n<p><strong>CREATE TABLE PARTITION OF<\/strong>. \u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0451 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430:<\/p>\n<pre><code>CREATE TABLE jan_sales PARTITION OF sales  FOR VALUES FROM ('2023-01-01') TO ('2023-02-01');<\/code><\/pre>\n<p><strong>ALTER TABLE ATTACH PARTITION<\/strong>. \u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430:<\/p>\n<pre><code>CREATE TABLE feb_sales (LIKE sales);  ALTER TABLE sales ATTACH PARTITION feb_sales  FOR VALUES FROM ('2024-02-01') TO ('2024-03-01');<\/code><\/pre>\n<p><strong>ALTER TABLE DETACH PARTITION<\/strong>. \u041a\u0430\u043a \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u0437 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0431\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b):<\/p>\n<pre><code>ALTER TABLE sales DETACH PARTITION jan_sales;<\/code><\/pre>\n<h4>\u041d\u043e\u0432\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445 \u0442\u0435\u043f\u0435\u0440\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <code>pg_partitioned_table<\/code> \u0438 \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044f\u0445 <code>pg_class<\/code> (relispartition \u0438 relpartbound). \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438: <code>pg_partition_ancestors(rel))<\/code>, <code>pg_partition_root(rel)<\/code> \u0438 <code>pg_partition_tree(rel)<\/code>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u0430\u0440\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, <code>pg_partition \u0438 pg_partition_rule<\/code>\u0443\u0448\u043b\u0438, \u043a\u0430\u043a \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>pg_partition_def()<\/code>.<\/p>\n<pre><code>-- New catalog for partitioned tables select * from pg_partitioned_table where partrelid = 'sales'::regclass;  partrelid | partstrat | partnatts | partdefid | partattrs | partclass | partcollation | partexprs -----------+-----------+-----------+-----------+-----------+-----------+---------------+-----------     156181 | r         |         1 |         0 | 2         | 3122      | 0             | (1 row)  -- A convenient helper routine to check the partition hierarchy select pg_partition_tree('sales');          pg_partition_tree -----------------------------------  (sales,,f,0)  (jan_sales,sales,t,1)  (sales_1_prt_feb_sales,sales,t,1)  (sales_1_prt_mar_sales,sales,t,1) (4 rows)<\/code><\/pre>\n<h3>\u041d\u043e\u0432\u044b\u0435 \u0432\u043e\u0440\u043a\u0444\u043b\u043e\u0443<\/h3>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430\u0445, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0442\u0435\u043c, \u0447\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 \u043b\u0435\u0433\u0430\u0441\u0438-\u043a\u043e\u043c\u0430\u043d\u0434\u044b Greenplum. <strong>\u0418 \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u0442\u0430\u043b \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c<\/strong>. \u0412\u0441\u0451 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u043d\u043e\u0432\u044b\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u044b \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0441 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0449\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0448\u0430\u043b\u0438 \u0441\u0442\u0430\u0440\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041d\u0438\u0436\u0435 \u043c\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.\u00a0<\/p>\n<p>\u041d\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u043e\u0432\u044b\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u044b \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0442\u0430\u0440\u044b\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0431\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u0432 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c<\/h4>\n<p>Greenplum \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date) (PARTITION jan_sales START ('2023-01-01') END ('2023-02-01'), PARTITION feb_sales START ('2023-02-01') END ('2023-03-01'), DEFAULT PARTITION other_sales);<\/code><\/pre>\n<p>\u0412 PostgreSQL \u043d\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0438:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date);  -- Add partition individually CREATE TABLE jan_sales PARTITION OF sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01'); CREATE TABLE feb_sales PARTITION OF sales FOR VALUES FROM ('2023-02-01') TO ('2023-03-01'); CREATE TABLE other_sales PARTITION OF sales DEFAULT;<\/code><\/pre>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432<\/h4>\n<p><code>ALTER TABLE... ADD PARTITION<\/code> \u0438 <code>CREATE TABLE... PARTITION OF<\/code> \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u043e\u0432\u0443\u044e \u0434\u043e\u0447\u0435\u0440\u043d\u044e\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>CREATE TABLE PARTITION OF<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>CREATE TABLE<\/code>, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>ADD PARTITION<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>ALTERTABLE<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CREATE TABLE ... PARTITION OF<\/code> \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446. <code>ADD PARTITION<\/code> \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<pre><code>-- CREATE TABLE allows you to specify more options CREATE TABLE jan_sales PARTITION OF sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01') USING ao_row  WITH(compresstype=zlib);  -- ADD PARTITION does the creation but have to specify options in separate commands ALTER TABLE sales ADD PARTITION jan_sales START ('2023-01-01') END ('2023-02-01');  ALTER TABLE sales_1_prt_jan_sales SET ACCESS METHOD ao_row; ALTER TABLE sales_1_prt_jan_sales SET WITH (compresstype=zlib);<\/code><\/pre>\n<h4>\u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439<\/h4>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code>EXCHANGE PARTITION<\/code> \u0432 \u043b\u0435\u0433\u0430\u0441\u0438-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. \u0421 \u043d\u043e\u0432\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>DETACH PARTITION<\/code> \u0438 <code>ATTACHPARTITION<\/code>, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u0433\u043e \u0436\u0435. \u0412\u043d\u0443\u0442\u0440\u0438 Greenplum 7 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f <code>DETACH<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c <code>ATTACHPARTITION<\/code> \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u0438\u043c\u0435\u043d.<\/p>\n<pre><code>-- 1. Using EXCHANGE PARTITION ALTER TABLE sales EXCHANGE jan_sales WITH TABLE jan_sales_new;        -- 2. Using ATTACH PARTITION ALTER TABLE sales DETACH PARTITION jan_sales; ALTER TABLE sales ATTACH PARTITION jan_sales_new;<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b<\/h4>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b, \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0412 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u043c Greenplum \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>ALTER TABLE ... DROP PARTITION<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0430\u043a\u0436\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u043d\u0430 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b. \u0422\u0435\u043f\u0435\u0440\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>ALTER TABLE ... DETACH PARTITION<\/code> \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0443 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0443:<\/p>\n<pre><code>-- Lengthy operations to remove an unwanted child partition w\/o dropping it: CREATE TABLE dummy (LIKE sales); ALTER TABLE sales EXCHANGE PARTITION archived_sales WITH dummy; ALTER TABLE sales DROP PARTITION archived_sales; DROP TABLE dummy;  -- Can just \"DETACH PARTITION\" now: ALTER TABLE sales DETACH PARTITION archived_sales;<\/code><\/pre>\n<p><code>ALTER TABLE ... DROP PARTITION<\/code> \u043f\u043e \u0441\u0443\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0442\u0443 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0443, \u0447\u0442\u043e \u0438 <code>DROP TABLE<\/code>. \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u0447\u0435\u043c\u0443 <code>ALTER TABLE ... DROP PARTITION<\/code> \u0432\u0441\u0435 \u0435\u0449\u0451 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442? \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0432\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b.\u00a0<\/p>\n<h4>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b<\/h4>\n<p><code>SPLIT PARTITION<\/code> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443: \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e \u0434\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430. \u042d\u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0431\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u0432 PostgreSQL. \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c.\u00a0<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041a\u0435\u0439\u0441<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u041b\u0435\u0433\u0430\u0441\u0438-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043d\u043e\u0432\u044b\u0439\/ \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">CREATE TABLE &#8230; (PARTITION &#8230;)<\/p>\n<\/td>\n<td>\n<p align=\"left\">CREATE TABLE &#8230; PARTITION BY and CREATE TABLE &#8230; PARTITION OF<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; ADD PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">CREATE TABLE &#8230; PARTITION OF<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; EXCHANGE PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; DETACH PARTITIONand ATTACH PARTITION<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; DROP PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">DROP TABLE<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; SPLIT PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">DETACH partition and ATTACH new ones separately<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u0414\u0440\u0443\u0433\u0438\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f<\/h3>\n<h4>\u0418\u043c\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0430 vs. \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h4>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0442\u0430\u043a, \u0447\u0442\u043e \u0438\u043c\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 DDL Greenplum, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u043c \u00ab\u0438\u043c\u0435\u043d\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u00bb \u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041f\u043e \u0441\u0443\u0442\u0438, Greenplum \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u0438\u043c\u0435\u043d\u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0435\u0444\u0438\u043a\u0441, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date) (PARTITION jan_sales START ('2023-01-01') END ('2023-02-01'));   ALTER TABLE sales ADD PARTITION feb_sales START ('2023-02-01') END ('2023-03-01');  \\d+ sales                                 Partitioned table \"public.sales\"  Column |     Type      | Collation | Nullable | Default | Storage | Stats target | Description --------+---------------+-----------+----------+---------+---------+--------------+-------------  id     | integer       |           |          |         | plain   |              |  date   | date          |           |          |         | plain   |              |  amt    | numeric(10,2) |           |          |         | main    |              | Partition key: RANGE (date) Partitions: sales_1_prt_feb_sales FOR VALUES FROM ('2023-02-01') TO ('2023-03-01'),             sales_1_prt_jan_sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01') Distributed by: (id) Access method: heap<\/code><\/pre>\n<p>\u0423 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <code>sales_1_prt_<\/code> \u043a \u0438\u043c\u0435\u043d\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0434\u043b\u044f \u043d\u0438\u0445 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c (<code>jan_sales<\/code> \u0438 <code>feb_sales<\/code>). \u041d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date);  CREATE TABLE jan_sales PARTITION OF sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01');  CREATE TABLE feb_sales (LIKE sales); ALTER TABLE sales ATTACH PARTITION feb_sales FOR VALUES FROM ('2024-02-01') TO ('2024-03-01');   \\d+ sales                                 Partitioned table \"public.sales\"  Column |     Type      | Collation | Nullable | Default | Storage | Stats target | Description --------+---------------+-----------+----------+---------+---------+--------------+-------------  id     | integer       |           |          |         | plain   |              |  date   | date          |           |          |         | plain   |              |  amt    | numeric(10,2) |           |          |         | main    |              | Partition key: RANGE (date) Partitions: feb_sales FOR VALUES FROM ('2024-02-01') TO ('2024-03-01'),             jan_sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01') Distributed by: (id) Access method: heap<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0430\u0440\u044b\u043c \u0438 \u043d\u043e\u0432\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 <code>DROP PARTITION<\/code>. \u041d\u043e \u043d\u0443\u0436\u043d\u043e, \u0435\u0441\u043b\u0438\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b <code>DETACH<\/code>:<\/p>\n<pre><code>-- Assuming we have the 'sales' partition with Jan and Feb  -- child partitions, created using legacy syntax. \\d+ sales                                 Partitioned table \"public.sales\"  Column |     Type      | Collation | Nullable | Default | Storage | Stats target | Description --------+---------------+-----------+----------+---------+---------+--------------+-------------  id     | integer       |           |          |         | plain   |              |  date   | date          |           |          |         | plain   |              |  amt    | numeric(10,2) |           |          |         | main    |              | Partition key: RANGE (date) Partitions: sales_1_prt_feb_sales FOR VALUES FROM ('2023-02-01') TO ('2023-03-01'),             sales_1_prt_jan_sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01') Distributed by: (id) Access method: heap  -- drop partition 'jan_sales', no problem ALTER TABLE sales DROP PARTITION jan_sales;  -- but couldn't detach, because there's no table named 'feb_sales' ALTER TABLE sales DETACH PARTITION feb_sales; ERROR:  relation \"feb_sales\" does not exist  -- have to specify full name using DETACH ALTER TABLE sales DETACH PARTITION sales_1_prt_feb_sales;<\/code><\/pre>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u043d\u043e\u0432\u044b\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u044b, \u043b\u0438\u0431\u043e \u043b\u0435\u0433\u0430\u0441\u0438-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u044b, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0434\u0432\u0443\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0451\u043d.<\/em><\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0438\u043b\u0438 \u043d\u0435\u0442<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0421\u0442\u0430\u0440\u044b\u0439 \u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0439<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">ADD PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Legacy<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">DROP PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Legacy<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">EXCHANGE PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Legacy<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">SPLIT PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Legacy<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">CREATE TABLE (PARTITION &#8230;)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Legacy<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">CREATE TABLE (EVERY &#8230;)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0434\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Legacy<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">CREATE TABLE &#8230; PARTITION OF<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">New<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">ATTACH PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">New<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">DETACH PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">New<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4>START|END vs FROM|TO<\/h4>\n<p>\u0418\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 SQL, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0440\u0430\u043d\u0435\u0435, \u0432\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0432 \u043d\u043e\u0432\u043e\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430: <code>FOR VALUES FROM ... TO ...<\/code>\u00a0. \u041b\u0435\u0433\u0430\u0441\u0438-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 Greenplum \u0438\u043c\u0435\u0435\u0442 <code>START ... END ()<\/code>. \u041e\u0431\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043b\u0435\u0433\u0430\u0441\u0438 \u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0445 DDL:<\/p>\n<pre><code>-- Both these work: ALTER TABLE sales ADD PARTITION mar_sales  START ('2023-03-01') END ('2023-03-31');  CREATE TABLE mar_sales PARTITION OF sales  FOR VALUES FROM ('2023-03-01') TO ('2023-03-31');  -- But these won't: ALTER TABLE sales ADD PARTITION mar_sales  FOR VALUES FROM ('2023-03-01') TO ('2023-03-31');  CREATE TABLE mar_sales PARTITION OF sales  START ('2023-03-01') END ('2023-03-31');<\/code><\/pre>\n<p>\u0412 \u043b\u0435\u0433\u0430\u0441\u0438-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 <code>EXCLUSIVE<\/code> \u0438 <code>INCLUSIVE<\/code> \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432. \u0412 PostgreSQL \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435\u0442, \u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f, \u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u2014 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f. Greenplum 7 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <code>EXCLUSIVE|INCLUSIVE<\/code>, \u043d\u0435\u044f\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u00ab+1\u00bb \u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c\u0443 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0443. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u00ab+\u00bb. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>integer<\/code> \u0438 <code>timestamp<\/code>, \u043d\u043e <code>float<\/code> \u0438\u043b\u0438 <code>text<\/code>.\u00a0<\/p>\n<pre><code>ALTER TABLE sales ADD PARTITION mar_sales START ('2023-03-01') INCLUSIVE END ('2023-03-31') INCLUSIVE;<\/code><\/pre>\n<h2>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u0430\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0432 ATTACH PARTITION<\/h2>\n<p><code>ATTACH PARTITION<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043e\u043d\u043e\u043f\u043e\u043b\u044c\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043e\u0431\u0449\u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u042d\u0442\u043e\u0442 \u0442\u0438\u043f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0438\u043c \u0438 \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u0435\u0442 \u0441\u043e \u043c\u043d\u043e\u0433\u0438\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>SELECT<\/code>, <code>INSERT<\/code> \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 <code>UPDATE<\/code>. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e Greenplum 7 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u0431\u0435\u0437 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0443 (\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>-- Assuming there's long-running insert INSERT INTO sales SELECT * FROM ext_sales_data;  -- This will be blocked ALTER TABLE sales ADD PARTITION march_sales START ('2023-03-01') END ('2023-04-01');  -- This will go through ALTER TABLE sales ATTACH PARTITION march_sales FOR VALUES FROM ('2023-03-01') TO ('2023-04-01');<\/code><\/pre>\n<h4>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/h4>\n<p>\u0413\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 <code>CHECK<\/code> \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u0442\u0435\u043f\u0435\u0440\u044c \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f.<\/p>\n<pre><code>-- same partition definition in Greenplum 6 and 7  -- Greenplum 6 \\d+ sales_1_prt_jan_sales                    Table \"public.sales_1_prt_jan_sales\"  Column |     Type      | Modifiers | Storage | Stats target | Description --------+---------------+-----------+---------+--------------+-------------  id     | integer       |           | plain   |              |  date   | date          |           | plain   |              |  amt    | numeric(10,2) |           | main    |              | Check constraints:     \"sales_1_prt_jan_sales_check\" CHECK (date >= '2023-01-01'::date AND date &lt; '2023-02-01'::date) Inherits: sales Distributed by: (id)  -- Greenplum 7 \\d+ jan_sales                                     Table \"public.jan_sales\"  Column |     Type      | Collation | Nullable | Default | Storage | Stats target | Description --------+---------------+-----------+----------+---------+---------+--------------+-------------  id     | integer       |           |          |         | plain   |              |  date   | date          |           |          |         | plain   |              |  amt    | numeric(10,2) |           |          |         | main    |              | Partition of: sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01') Partition constraint: ((date IS NOT NULL) AND (date >= '2023-01-01'::date) AND (date &lt; '2023-02-01'::date)) Distributed by: (id)<\/code><\/pre>\n<h4>PARTITION BY \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438<\/h4>\n<p>\u0420\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0442\u0438\u043f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>-- This is no longer working: CREATE TABLE foo (a int, b int, c int) PARTITION BY list (b,c); ERROR:  cannot use \"list\" partition strategy with more than one column  -- Alternatively: CREATE TYPE partkey as (b int, c int); CREATE TABLE foo (a int, b int, c int) PARTITION BY LIST ((row(b, c)::partkey));<\/code><\/pre>\n<h3>\u041a\u043e\u0440\u043e\u0442\u043a\u043e \u043e \u0433\u043b\u0430\u0432\u043d\u043e\u043c<\/h3>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f Greenplum 7 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0421\u0423\u0411\u0414. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438, \u043d\u0430 \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043b\u0435\u0433\u0430\u0441\u0438- \u0438 \u043d\u043e\u0432\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/206\/691\/0ad\/2066910ad2a7f753101dcc8cbcc832e9.jpg\" alt=\"\" title=\"\" width=\"780\" height=\"100\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/206\/691\/0ad\/2066910ad2a7f753101dcc8cbcc832e9.jpg\" data-blurred=\"true\"\/><\/figure>\n<p><a href=\"https:\/\/slurm.io\/green-plum?utm_source=habr&amp;utm_medium=promo&amp;utm_campaign=green-plum&amp;utm_content=promo_31-03-2023&amp;utm_term=gornushkina\"><u>\u00abDWH\u00a0\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435\u00a0GreenPlum\u00bb<\/u><\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/726070\/\"> https:\/\/habr.com\/ru\/articles\/726070\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Greenplum 7 \u2014 \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0421\u0423\u0411\u0414, \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430\u044f \u0441 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0438\u0437 PostgreSQL: World DB.\u00a0<\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f: \u0434\u043e PostgreSQL 10 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 PostgreSQL \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u043e\u0441\u044c \u0432 \u043e\u0447\u0435\u043d\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0438 \u043f\u043e \u0441\u0443\u0442\u0438, \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 PostgreSQL 10, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432.\u00a0<\/p>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u043b\u0438\u044f\u043d\u0438\u044f \u0441 PostgreSQL 12 Greenplum 7 \u0432\u043e\u0431\u0440\u0430\u043b \u0432 \u0441\u0435\u0431\u044f \u0432\u0435\u0441\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 PostgreSQL \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 Greenplum. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 Greenplum 7 \u0435\u0441\u0442\u044c \u0448\u0430\u043d\u0441 \u0432\u0437\u044f\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0435 \u0438\u0437 \u043e\u0431\u043e\u0438\u0445 \u043c\u0438\u0440\u043e\u0432 \u2014 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e, \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.\u00a0<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>\u041d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043d\u0430\u0447\u043d\u0451\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0432 Greenplum 7, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.\u00a0<\/p>\n<p>PostgreSQL \u0438\u043c\u0435\u0435\u0442 \u0442\u043e \u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0438 Greenplum, \u2014 <code>PARTITION BY<\/code>. \u041e\u043d\u043e \u0436\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 Greenplum 7. \u0422\u0430\u043a\u0436\u0435 \u0443 PostgreSQL \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f <code>RANGE<\/code> \u0438 <code>LIST<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Greenplum \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0432 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438. \u041d\u043e \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435: Greenplum 7 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0435\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date);<\/code><\/pre>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code>CREATE TABLE ... PARTITION BY<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432. \u0414\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u0432 Greenplum 7 \u2014 \u044d\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 (\u0438\u0445 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445).\u00a0<\/p>\n<figure class=\"full-width\"><\/figure>\n<p><a href=\"https:\/\/slurm.io\/green-plum?utm_source=habr&amp;utm_medium=promo&amp;utm_campaign=green-plum&amp;utm_content=promo_31-03-2023&amp;utm_term=gornushkina\"><u>\u00abDWH\u00a0\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435\u00a0GreenPlum\u00bb<\/u><\/a><\/p>\n<h3>\u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0445\u0435\u0448\u0430<\/h3>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>RANGE<\/code> \u0438 <code>LIST<\/code> Greenplum 7 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <code>HASH<\/code>. \u042d\u0442\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 PostgreSQL. \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0445\u044d\u0448-\u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0435\u0451 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432:<\/p>\n<pre><code>-- create a tabled partitioned by hash strategy CREATE TABLE sales_by_hour (id int, date date, hour int, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY HASH (hour);  -- every hash partition modulus must be a factor of the next larger modulus CREATE TABLE sales_by_hour_1 PARTITION OF sales_by_hour FOR VALUES WITH (MODULUS 24, REMAINDER 0); CREATE TABLE sales_by_hour_2 PARTITION OF sales_by_hour FOR VALUES WITH (MODULUS 24, REMAINDER 1); CREATE TABLE sales_by_hour_3 PARTITION OF sales_by_hour FOR VALUES WITH (MODULUS 24, REMAINDER 2); ......<\/code><\/pre>\n<h4>\u041d\u043e\u0432\u044b\u0439 DDL<\/h4>\n<p>\u041e\u0431\u0441\u0443\u0434\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f Greenplum 7, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 DDL.<\/p>\n<p><strong>CREATE TABLE PARTITION OF<\/strong>. \u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0451 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430:<\/p>\n<pre><code>CREATE TABLE jan_sales PARTITION OF sales  FOR VALUES FROM ('2023-01-01') TO ('2023-02-01');<\/code><\/pre>\n<p><strong>ALTER TABLE ATTACH PARTITION<\/strong>. \u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430:<\/p>\n<pre><code>CREATE TABLE feb_sales (LIKE sales);  ALTER TABLE sales ATTACH PARTITION feb_sales  FOR VALUES FROM ('2024-02-01') TO ('2024-03-01');<\/code><\/pre>\n<p><strong>ALTER TABLE DETACH PARTITION<\/strong>. \u041a\u0430\u043a \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u0437 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0431\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b):<\/p>\n<pre><code>ALTER TABLE sales DETACH PARTITION jan_sales;<\/code><\/pre>\n<h4>\u041d\u043e\u0432\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u0445 \u0442\u0435\u043f\u0435\u0440\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <code>pg_partitioned_table<\/code> \u0438 \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044f\u0445 <code>pg_class<\/code> (relispartition \u0438 relpartbound). \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438: <code>pg_partition_ancestors(rel))<\/code>, <code>pg_partition_root(rel)<\/code> \u0438 <code>pg_partition_tree(rel)<\/code>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u0430\u0440\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, <code>pg_partition \u0438 pg_partition_rule<\/code>\u0443\u0448\u043b\u0438, \u043a\u0430\u043a \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>pg_partition_def()<\/code>.<\/p>\n<pre><code>-- New catalog for partitioned tables select * from pg_partitioned_table where partrelid = 'sales'::regclass;  partrelid | partstrat | partnatts | partdefid | partattrs | partclass | partcollation | partexprs -----------+-----------+-----------+-----------+-----------+-----------+---------------+-----------     156181 | r         |         1 |         0 | 2         | 3122      | 0             | (1 row)  -- A convenient helper routine to check the partition hierarchy select pg_partition_tree('sales');          pg_partition_tree -----------------------------------  (sales,,f,0)  (jan_sales,sales,t,1)  (sales_1_prt_feb_sales,sales,t,1)  (sales_1_prt_mar_sales,sales,t,1) (4 rows)<\/code><\/pre>\n<h3>\u041d\u043e\u0432\u044b\u0435 \u0432\u043e\u0440\u043a\u0444\u043b\u043e\u0443<\/h3>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0432\u0435\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043e \u043d\u043e\u0432\u044b\u0445 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430\u0445, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0442\u0435\u043c, \u0447\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 \u043b\u0435\u0433\u0430\u0441\u0438-\u043a\u043e\u043c\u0430\u043d\u0434\u044b Greenplum. <strong>\u0418 \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u0442\u0430\u043b \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c<\/strong>. \u0412\u0441\u0451 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u043d\u043e\u0432\u044b\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u044b \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0441 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0449\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0448\u0430\u043b\u0438 \u0441\u0442\u0430\u0440\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041d\u0438\u0436\u0435 \u043c\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.\u00a0<\/p>\n<p>\u041d\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u043e\u0432\u044b\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u044b \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0442\u0430\u0440\u044b\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0431\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u0432 (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c<\/h4>\n<p>Greenplum \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date) (PARTITION jan_sales START ('2023-01-01') END ('2023-02-01'), PARTITION feb_sales START ('2023-02-01') END ('2023-03-01'), DEFAULT PARTITION other_sales);<\/code><\/pre>\n<p>\u0412 PostgreSQL \u043d\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0438:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date);  -- Add partition individually CREATE TABLE jan_sales PARTITION OF sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01'); CREATE TABLE feb_sales PARTITION OF sales FOR VALUES FROM ('2023-02-01') TO ('2023-03-01'); CREATE TABLE other_sales PARTITION OF sales DEFAULT;<\/code><\/pre>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432<\/h4>\n<p><code>ALTER TABLE... ADD PARTITION<\/code> \u0438 <code>CREATE TABLE... PARTITION OF<\/code> \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u043e\u0432\u0443\u044e \u0434\u043e\u0447\u0435\u0440\u043d\u044e\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>CREATE TABLE PARTITION OF<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>CREATE TABLE<\/code>, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>ADD PARTITION<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>ALTERTABLE<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CREATE TABLE ... PARTITION OF<\/code> \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446. <code>ADD PARTITION<\/code> \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<pre><code>-- CREATE TABLE allows you to specify more options CREATE TABLE jan_sales PARTITION OF sales FOR VALUES FROM ('2023-01-01') TO ('2023-02-01') USING ao_row  WITH(compresstype=zlib);  -- ADD PARTITION does the creation but have to specify options in separate commands ALTER TABLE sales ADD PARTITION jan_sales START ('2023-01-01') END ('2023-02-01');  ALTER TABLE sales_1_prt_jan_sales SET ACCESS METHOD ao_row; ALTER TABLE sales_1_prt_jan_sales SET WITH (compresstype=zlib);<\/code><\/pre>\n<h4>\u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439<\/h4>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code>EXCHANGE PARTITION<\/code> \u0432 \u043b\u0435\u0433\u0430\u0441\u0438-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. \u0421 \u043d\u043e\u0432\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>DETACH PARTITION<\/code> \u0438 <code>ATTACHPARTITION<\/code>, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u0433\u043e \u0436\u0435. \u0412\u043d\u0443\u0442\u0440\u0438 Greenplum 7 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f <code>DETACH<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c <code>ATTACHPARTITION<\/code> \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u0438\u043c\u0435\u043d.<\/p>\n<pre><code>-- 1. Using EXCHANGE PARTITION ALTER TABLE sales EXCHANGE jan_sales WITH TABLE jan_sales_new;        -- 2. Using ATTACH PARTITION ALTER TABLE sales DETACH PARTITION jan_sales; ALTER TABLE sales ATTACH PARTITION jan_sales_new;<\/code><\/pre>\n<h4>\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b<\/h4>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b, \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0412 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u043c Greenplum \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>ALTER TABLE ... DROP PARTITION<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0430\u043a\u0436\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u043d\u0430 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b. \u0422\u0435\u043f\u0435\u0440\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>ALTER TABLE ... DETACH PARTITION<\/code> \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0443 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0443:<\/p>\n<pre><code>-- Lengthy operations to remove an unwanted child partition w\/o dropping it: CREATE TABLE dummy (LIKE sales); ALTER TABLE sales EXCHANGE PARTITION archived_sales WITH dummy; ALTER TABLE sales DROP PARTITION archived_sales; DROP TABLE dummy;  -- Can just \"DETACH PARTITION\" now: ALTER TABLE sales DETACH PARTITION archived_sales;<\/code><\/pre>\n<p><code>ALTER TABLE ... DROP PARTITION<\/code> \u043f\u043e \u0441\u0443\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0442\u0443 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0443, \u0447\u0442\u043e \u0438 <code>DROP TABLE<\/code>. \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u0447\u0435\u043c\u0443 <code>ALTER TABLE ... DROP PARTITION<\/code> \u0432\u0441\u0435 \u0435\u0449\u0451 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442? \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0432\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b.\u00a0<\/p>\n<h4>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b<\/h4>\n<p><code>SPLIT PARTITION<\/code> \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443: \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e \u0434\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430. \u042d\u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0431\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u0432 PostgreSQL. \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c.\u00a0<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041a\u0435\u0439\u0441<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u041b\u0435\u0433\u0430\u0441\u0438-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043d\u043e\u0432\u044b\u0439\/ \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c<\/p>\n<\/td>\n<td>\n<p align=\"left\">CREATE TABLE &#8230; (PARTITION &#8230;)<\/p>\n<\/td>\n<td>\n<p align=\"left\">CREATE TABLE &#8230; PARTITION BY and CREATE TABLE &#8230; PARTITION OF<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; ADD PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">CREATE TABLE &#8230; PARTITION OF<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; EXCHANGE PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; DETACH PARTITIONand ATTACH PARTITION<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; DROP PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">DROP TABLE<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b<\/p>\n<\/td>\n<td>\n<p align=\"left\">ALTER TABLE &#8230; SPLIT PARTITION<\/p>\n<\/td>\n<td>\n<p align=\"left\">DETACH partition and ATTACH new ones separately<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u0414\u0440\u0443\u0433\u0438\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f<\/h3>\n<h4>\u0418\u043c\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0430 vs. \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h4>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0442\u0430\u043a, \u0447\u0442\u043e \u0438\u043c\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 DDL Greenplum, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u043c \u00ab\u0438\u043c\u0435\u043d\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u00bb \u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041f\u043e \u0441\u0443\u0442\u0438, Greenplum \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u0438\u043c\u0435\u043d\u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0435\u0444\u0438\u043a\u0441, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432:<\/p>\n<pre><code>CREATE TABLE sales (id int, date date, amt decimal(10,2)) DISTRIBUTED BY (id) PARTITION BY RANGE (date) (PARTITION jan_sales START ('2023-01-01') END ('2023-02-01'));   ALTER TABLE sales ADD PARTITION feb_sales START ('2023-02-01') END ('2023-03-01');  \\d+ sales                                 Partitioned table \"public.sales\"  Column |     Type      | Collation | Nullable | Default | Storage | Stats target | Description<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-408089","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/408089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=408089"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/408089\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=408089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=408089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=408089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}