{"id":444773,"date":"2025-01-12T09:00:48","date_gmt":"2025-01-12T09:00:48","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=444773"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=444773","title":{"rendered":"<span>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u00abduplicate key value violates unique constraint \u00abpg_class_relname_nsp_index\u00bb\u00bb \u0432 PostgreSQL<\/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> \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u00abduplicate key value violates unique constraint &#171;pg_class_relname_nsp_index&#187;\u00bb \u0432 PostgreSQL, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 \u0432 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p>\u0421\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043c\u0435\u043d \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0441\u0435\u043a\u0446\u0438\u0439, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c <a href=\"https:\/\/habr.com\/ru\/articles\/791204\/\">Postgres<\/a> \u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445, \u0434\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0432\u0443\u0445 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430, \u043d\u043e \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430, \u0441 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0439, \u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u0435\u0440\u0435, \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043a\u0446\u0438\u0435\u0439 \u043d\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435. \u0410 \u044d\u0442\u043e\u0442 exception \u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u0431\u0430\u0433\u043e\u043c Postgres. \u041d\u043e \u0434\u0430\u043b\u0435\u0435, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u0432\u043d\u043e\u0432\u044c \u0438 \u0432\u043d\u043e\u0432\u044c, \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0438, \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0438\u043c\u0435\u043d, \u0434\u043b\u0438\u043d\u043e\u0439 \u043e\u043a\u043e\u043b\u043e 30 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0430 \u044d\u0442\u043e \u0432 \u0434\u0432\u0430 \u0441 \u043b\u0438\u0448\u043d\u0438\u043c \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f Postgres \u0432 63 \u0441\u0438\u043c\u0432\u043e\u043b\u0430). \u041f\u0440\u0438\u0447\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u043c\u0435\u043b\u0430 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440: \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0441\u0442\u0435\u043d\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0434\u0430\u0447\u043d\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443, \u0430 \u043f\u0440\u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u043d\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u0442\u0435\u043d\u0434\u0435 \u0441\u0431\u043e\u0440\u043a\u0430 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439. \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435\u0437\u0430\u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 &#8212; \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0432\u043d\u0443\u0442\u0440\u0438\u043f\u0440\u043e\u0435\u043a\u0442\u043d\u043e\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043e \u043d\u0435\u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u0430 \u0434\u043b\u044f \u0438\u043c\u0435\u043d. \u041d\u043e 30 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 &#8212; \u044d\u0442\u043e \u043c\u0430\u043b\u043e. \u0412 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0432 Oracle (\u0432 \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0436\u0435 \u0441\u0442\u0430\u0440\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445), \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 30 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043c\u0435\u043d\u044f \u043b\u0438\u0447\u043d\u043e, \u0443\u0433\u043d\u0435\u0442\u0430\u043b\u043e. \u0412 \u0440\u044f\u0434\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u043d\u0435 \u0443\u0445\u0443\u0434\u0448\u0430\u044e\u0442 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 \u0435\u0435, \u0432\u043d\u043e\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f (\u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u043f\u043e \u043f\u0440\u043e\u0448\u0435\u0441\u0442\u0432\u0438\u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043f\u043e\u0434\u0431\u043e\u0440 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0437\u0430\u043d\u044f\u0442\u0438\u0435\u043c, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f. \u0418, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u0432\u044b\u0431\u0438\u0440\u0430\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u043c\u044b \u0437\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u0443 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f &#8212; \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0439 &#8212; \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u0430\u044f \u0438 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430. \u0422.\u043e. \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u0441 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u044f\u043b, \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 \u043b\u0435\u0433\u0447\u0435, \u0435\u0441\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u0435\u0435, \u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c \u044d\u0442\u0438\u0445 \u0438\u043c\u0435\u043d \u0431\u044b\u043b\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 (\u0438\u043d\u0430\u0447\u0435, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 \u0438\/\u0438\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439).<\/p>\n<p>\u0414\u043b\u044f\u00a0\u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e\u00a0\u044d\u0442\u043e \u0437\u0430\u00a0unique constraint:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/41d\/d93\/b49\/41dd93b4975558ff1a4ab38c227cc000.png\" width=\"780\" height=\"172\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/41d\/d93\/b49\/41dd93b4975558ff1a4ab38c227cc000.png\"\/><\/figure>\n<p>\u041d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432 \u0438\u043c\u0435\u043d\u0430\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u044d\u0442\u043e \u043f\u043e\u043a\u0430 \u044f\u0432\u043d\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 &#8212; \u044d\u0442\u043e \u0436\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 pg_catalog.pg_class \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0411\u0414 (\u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0442\u0430\u0431\u043b\u0438\u0446):<\/p>\n<pre><code class=\"sql\">select      relkind, *  from      pg_catalog.pg_class  where      not (relkind = any('{i, I}'::char[]))<\/code><\/pre>\n<p>\u0412 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u0443\u0442\u0430\u0442\u044c \u043d\u0430\u0448\u0443: <a href=\"https:\/\/www.google.com\/search?q=duplicate+key+value+violates+unique+constraint+%22pg_type_typname_nsp_index%22&amp;sca_esv=e7a01fb2273cd8ce&amp;sxsrf=ADLYWIJmu-cnpjRphmnyzBIbGu0qBEnzVw%3A1736581602557&amp;ei=4iGCZ6fUIbSC9u8P8u_ZiA4&amp;ved=0ahUKEwinzazMlu2KAxU0gf0HHfJ3FuEQ4dUDCBA&amp;uact=5&amp;oq=duplicate+key+value+violates+unique+constraint+%22pg_type_typname_nsp_index%22&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiSmR1cGxpY2F0ZSBrZXkgdmFsdWUgdmlvbGF0ZXMgdW5pcXVlIGNvbnN0cmFpbnQgInBnX3R5cGVfdHlwbmFtZV9uc3BfaW5kZXgiSKkOUO4IWO4IcAF4AZABAJgBgwGgAYMBqgEDMC4xuAEDyAEA-AEC-AEBmAIBoAIIwgIKEAAYsAMY1gQYR5gDAIgGAZAGCJIHATGgB4AB&amp;sclient=gws-wiz-serp\">duplicate key value violates unique constraint &#171;pg_type_typname_nsp_index&#187;<\/a>, &#8212; \u043e\u043d\u0430, \u043a\u0430\u043a \u0440\u0430\u0437, \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432 \u0438\u043c\u0435\u043d\u0430\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u0438 \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c. \u041e\u043d\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 &#8212; \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eab\/e6e\/e9a\/eabe6ee9a1891d6200459638944962eb.png\" width=\"381\" height=\"126\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eab\/e6e\/e9a\/eabe6ee9a1891d6200459638944962eb.png\"\/><\/figure>\n<p>\u041c\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u0438\u0445 \u0438 \u0442\u0435\u0445 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u044f\u0445 &#8212; \u044d\u0442\u043e \u044f\u0432\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u0421\u0423\u0411\u0414 &#8212; \u044d\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e &#171;\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435&#187; \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 DDL \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0438\u043b\u0438 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0442\u043e\u0433\u043e middleware, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442). \u0412 \u043d\u0430\u0448\u0435\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 &#171;\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435&#187; &#8212; \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c, \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0440\u0430\u0437\u043d\u044b\u0435, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442, \u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u044f\u0445.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>the_table_with_a_really_long_descriptive_name_1<\/p>\n<\/li>\n<li>\n<p>the_table_with_a_really_long_descriptive_name_2<\/p>\n<\/li>\n<li>\n<p>the_table_with_a_really_long_descriptive_name_3<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u0430\u0436\u0434\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0438\u043d\u0434\u0435\u043a\u0441:<\/p>\n<pre><code class=\"sql\">create table     the_table_with_a_really_long_descriptive_name_1 (         key_field integer         , some_attribute integer     )     partition by          list(key_field) ;  create index i_the_table_with_a_really_long_descriptive_name_1$some_attribute      on the_table_with_a_really_long_descriptive_name_1 (         some_attribute     ) ;<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0435\u043a\u0446\u0438\u044f\u0445. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<\/p>\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 shell-\u0441\u043a\u0440\u0438\u043f\u0442 \u0441 psql, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0448\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435, \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0442\u0440\u0435\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u043a\u0436\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<pre><code class=\"bash\">#!\/bin\/bash  pg_connection_string=\"postgresql:\/\/postgres@localhost:5432\/postgres\"  function create_partitioned_table() {     echo \"         \\set ON_ERROR_STOP true         \\         drop table if exists              the_table_with_a_short_name_$1         ;                  create table             the_table_with_a_short_name_$1 (                 key_field integer                 , some_attribute integer             )             partition by                  list(key_field)         ;                  create index i_the_table_with_a_short_name_$1$some_attribute              on the_table_with_a_short_name_$1 (                 some_attribute             )         ;         \\         do \\$plsql\\$         begin             for i in 1..3 loop                 execute                     format(                         \\$dml\\$                         create table                              the_table_with_a_short_name_$1\\$partition%s                          partition of                              the_table_with_a_short_name_$1                         for values                             in (%s)                         \\$dml\\$                         , i                         , i                     )                 ;             end loop             ;         end         \\$plsql\\$         ;         \\         drop table if exists              the_table_with_a_really_long_descriptive_name_$1         ;                  create table             the_table_with_a_really_long_descriptive_name_$1 (                 key_field integer                 , some_attribute integer             )             partition by                  list(key_field)         ;                  create index i_the_table_with_a_really_long_descriptive_name_$1$some_attribute              on the_table_with_a_really_long_descriptive_name_$1 (                 some_attribute             )         ;         \\         do \\$plsql\\$         begin             for i in 1..3 loop                 execute                     format(                         \\$dml\\$                         create table                              the_table_with_a_really_long_descriptive_name_$1\\$partition%s                          partition of                              the_table_with_a_really_long_descriptive_name_$1                         for values                             in (%s)                         \\$dml\\$                         , i                         , i                     )                 ;             end loop             ;         end         \\$plsql\\$         ;     \" |     psql \\         --dbname=$pg_connection_string \\         --quiet     sleep 1 }  execute_in_parallel=\"$1\" # specify \"true\" to execute in parallel  for i in {1..3} do     if [[ $execute_in_parallel = \"true\" ]]; then          create_partitioned_table $i &amp; # execution in the background     else         create_partitioned_table $i     fi done  wait  psql \\     --dbname=$pg_connection_string \\     --command=\"\\di\"  echo \"All done\"<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a, \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b Postgres: \u0443 \u0438\u043c\u0435\u043d \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u043a\u0446\u0438\u0439, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0438\u043c\u0435\u043d\u0438 \u0441\u0435\u043a\u0446\u0438\u0438, \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0444\u0438\u043a\u0441 &#171;i_&#187;, \u0438, \u043f\u0440\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043b\u0438\u043c\u0438\u0442\u0430 \u043f\u043e \u0434\u043b\u0438\u043d\u0435 (63 \u0441\u0438\u043c\u0432\u043e\u043b\u0430), \u0432\u044b\u0440\u0435\u0437\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c (\u0433\u0434\u0435-\u0442\u043e, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u0440\u0435\u0442\u0438), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441 &#171;_idx[N]&#187;.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a6e\/962\/987\/a6e9629878b267c5389a6861406a2cd8.png\" width=\"1340\" height=\"540\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a6e\/962\/987\/a6e9629878b267c5389a6861406a2cd8.png\"\/><\/figure>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440), \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u043a\u043e\u043c\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 (\u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0440\u0430\u0437\u043d\u044b\u043c\u0438, \u0442.\u043a. \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ab8\/f2a\/9a4\/ab8f2a9a40d8d6a5fdcd00ba7d590e69.png\" width=\"1342\" height=\"799\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab8\/f2a\/9a4\/ab8f2a9a40d8d6a5fdcd00ba7d590e69.png\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u043c\u0435\u043d \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0432 \u0438\u0442\u043e\u0433\u0435, \u043d\u0435 \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u043b\u0438\u043d\u0435; \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, exception \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0438\u0437-\u0437\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0431\u0430\u0433\u0430 Postgres &#8212; \u043f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0430 \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043f\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0441\u0435\u043a\u0446\u0438\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 &#8212; \u0442.\u0435. \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0421\u0423\u0411\u0414, \u0434\u0443\u043c\u0430\u044e, \u043d\u0435\u0442. \u0415\u0449\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u0435\u043a\u0446\u0438\u0439 \u0432 \u043e\u0434\u043d\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#8212; \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c\u0438 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0434\u0432\u0443\u043c\u044f \u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, &#8212; \u0442.\u043a. \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u043a\u0446\u0438\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0435\u0434\u0438\u043d\u043e\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0441\u0435\u043a\u0446\u0438\u0438 (create table &#8230; partition of &#8230; \u0438\u043b\u0438 alter table &#8230; attach partition &#8230;), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u044b\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043b\u0435\u0436\u0438\u0442 \u0438\u0434\u0435\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442.\u043d. \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0438\u043c\u0435\u044e\u0449\u0435\u0439 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0442\u0430\u043a\u0438\u0445 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre><code class=\"sql\">create or replace view v_orderliness_logical_dependency as with      partitioned_table as (         select              n.nspname as schema_name             , t.relname as table_name             , t.oid as table_id         from              pg_catalog.pg_class t         join pg_catalog.pg_namespace n             on n.oid = t.relnamespace         where             t.relkind = 'p'::\"char\"     )     , name_length_limit as (         select              s.setting::integer \/ 2 - 2 as max_len         from              pg_catalog.pg_settings s         where              s.name = 'max_identifier_length'     )     , orderliness_logical_dependency as (         select             t.schema_name             , t.group_name             , array_agg(t.table_id order by t.table_name) as table_seq         from (             select                  t.schema_name                 , t.table_name                 , t.table_id                 , left(t.table_name, n.max_len) as group_name             from                  partitioned_table t             cross join name_length_limit n         ) t         group by             t.schema_name             , t.group_name         having              count(*) &gt; 1     )     , dependency_group_item as (         select              dep.schema_name             , dep.group_name             , t.table_id             , pt.table_name             , t.ordinal_num         from              orderliness_logical_dependency dep         cross join lateral unnest(dep.table_seq)              with ordinality as t(table_id, ordinal_num)         join partitioned_table pt              on pt.table_id = t.table_id     ) select     forward_table.schema_name     , forward_table.table_name as forward_table_name     , forward_table.table_id as forward_table_id     , following_table.table_name as following_table_name     , following_table.table_id as following_table_id from      dependency_group_item forward_table join dependency_group_item following_table     on following_table.schema_name = forward_table.schema_name     and following_table.group_name = forward_table.group_name     and following_table.ordinal_num &gt; forward_table.ordinal_num ;<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u044b \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u0438\u043c\u0435\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u043e \u043f\u0435\u0440\u0432\u044b\u043c 29 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c. \u0414\u0430\u043b\u0435\u0435, \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0430\u043a\u043e\u0439 \u043f\u0430\u0440\u0435, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0438\u043c\u0435\u043d\u0438, \u043f\u0435\u0440\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0433\u043b\u0430\u0432\u043d\u0430\u044f, \u0432\u0442\u043e\u0440\u0430\u044f &#8212; \u043a\u0430\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0430\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d2b\/bf7\/daa\/d2bbf7daa55bd43cc8fa4775c0bb7eb8.png\" width=\"1234\" height=\"123\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d2b\/bf7\/daa\/d2bbf7daa55bd43cc8fa4775c0bb7eb8.png\"\/><\/figure>\n<p>\u0414\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0442\u0440\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0432\u044f\u0437\u0435\u0439: \u0432\u0442\u043e\u0440\u0430\u044f \u0438 \u0442\u0440\u0435\u0442\u044c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0439, \u0442\u0440\u0435\u0442\u044c\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0442\u043e\u0440\u043e\u0439.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e \u0442.\u043d. &#171;\u0446\u0435\u043f\u043e\u0447\u043a\u0430\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438&#187;.<\/p>\n<pre><code class=\"sql\">create or replace view v_partitioned_table_processing_chain as with recursive      table_dependency as (         select              forward_table_id as primary_table_id             , following_table_id as dependent_table_id         from              v_orderliness_logical_dependency     )     , selected_table as (         select              n.nspname as schema_name             , t.relname as table_name             , t.oid as table_id         from              pg_catalog.pg_class t         join pg_catalog.pg_namespace n             on n.oid = t.relnamespace         where             t.relkind = 'p'::\"char\"     )     , target_table as (         select              t.table_id             , dep.primary_table_id             , case                 when dep.primary_table_id is not null then 1                 else 0             end as dep_level         from              selected_table t         left join table_dependency dep              on dep.dependent_table_id = t.table_id         union all         select             t.table_id             , dep.primary_table_id             , t.dep_level + 1 as dep_level          from              target_table t         join table_dependency dep              on dep.dependent_table_id = t.primary_table_id     ) select      t.schema_name     , t.table_name     , t.table_id     , t.dep_level     , coalesce(         t.primary_table_id         , t.table_id     ) as safe_parallel_processing_chain_id from (     select          st.schema_name         , st.table_name         , t.table_id         , t.dep_level         , t.primary_table_id         , row_number()             over (                 partition by                      t.table_id                 order by                      t.dep_level desc             )              as ordinal_number     from          target_table t     join selected_table st          on st.table_id = t.table_id ) t  where      t.ordinal_number = 1 order by      dep_level     , table_name     ;<\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438\u0441\u044c \u043f\u043e \u0447\u0435\u0442\u044b\u0440\u0435\u043c &#171;\u0446\u0435\u043f\u043e\u0447\u043a\u0430\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438&#187;: \u0442\u0440\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043b\u0438\u0441\u044c \u0432 \u043e\u0434\u043d\u0443 \u043e\u0431\u0449\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430; \u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u0441\u0432\u043e\u044e \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b64\/84d\/f84\/b6484df8448bb32a6539c7861211403e.png\" width=\"1008\" height=\"193\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b64\/84d\/f84\/b6484df8448bb32a6539c7861211403e.png\"\/><\/figure>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 shell-\u0441\u043a\u0440\u0438\u043f\u0442, \u0432\u043d\u0435\u0434\u0440\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u043d\u043e\u0432\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0445 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u0432 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435;<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u0430\u043f\u0435, \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u043a\u0446\u0438\u0439 &#8212; \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0447\u043d\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">#!\/bin\/bash  pg_connection_string=\"postgresql:\/\/postgres@localhost:5432\/postgres\"  function create_partitioned_table() {     echo \"         \\set ON_ERROR_STOP true         \\         drop table if exists              the_table_with_a_short_name_$1         ;                  create table             the_table_with_a_short_name_$1 (                 key_field integer                 , some_attribute integer             )             partition by                  list(key_field)         ;                  create index i_the_table_with_a_short_name_$1$some_attribute              on the_table_with_a_short_name_$1 (                 some_attribute             )         ;         \\         drop table if exists              the_table_with_a_really_long_descriptive_name_$1         ;                  create table             the_table_with_a_really_long_descriptive_name_$1 (                 key_field integer                 , some_attribute integer             )             partition by                  list(key_field)         ;                  create index i_the_table_with_a_really_long_descriptive_name_$1$some_attribute              on the_table_with_a_really_long_descriptive_name_$1 (                 some_attribute             )         ;     \" |     psql \\         --dbname=$pg_connection_string \\         --quiet     sleep 1 }  function create_table_partitions() {     echo \"         \\set ON_ERROR_STOP true         \\         do \\$plsql\\$         declare              l_table_rec record;         begin             for l_table_rec in (                 select                      table_name                 from                      v_partitioned_table_processing_chain                 where                      safe_parallel_processing_chain_id = $1                 order by                      dep_level             )              loop                 &lt;&lt;partitions_creation&gt;&gt;                 for i in 1..3 loop                     execute                         format(                             \\$dml\\$                             create table                                  %s\\$partition%s                              partition of                                  %s                             for values                                 in (%s)                             \\$dml\\$                             , l_table_rec.table_name                             , i                             , l_table_rec.table_name                             , i                         )                     ;                 end loop                 ;             end loop             ;         end         \\$plsql\\$         ;     \" |     psql \\         --dbname=$pg_connection_string \\         --quiet     sleep 1 }  execute_in_parallel=\"$1\" # specify \"true\" to execute in parallel  for i in {1..3} do     create_partitioned_table $i done  temp_dir=\"$(mktemp -d)\"  processing_chains=\"$temp_dir\/processing_chains\"  echo \"     select distinct         safe_parallel_processing_chain_id     from         v_partitioned_table_processing_chain \" | \\ psql $pg_connection_string \\     --tuples-only \\     --no-align \\     --field-separator=$'\\t' \\     &gt; $processing_chains  while IFS=$'\\n\\t' read -r safe_parallel_processing_chain_id; do     if [[ $execute_in_parallel = \"true\" ]]; then          create_table_partitions $safe_parallel_processing_chain_id &amp; # execution in the background     else         create_table_partitions $safe_parallel_processing_chain_id     fi done &lt; $processing_chains  wait  rm -r \"$temp_dir\"  psql \\     --dbname=$pg_connection_string \\     --command=\"\\di\"  echo \"All done\"<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u043e\u0448\u0438\u0431\u043a\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/669\/bea\/f7e\/669beaf7e98c345304942477eb9c0237.png\" width=\"1344\" height=\"530\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/669\/bea\/f7e\/669beaf7e98c345304942477eb9c0237.png\"\/><\/figure>\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\/872990\/\"> https:\/\/habr.com\/ru\/articles\/872990\/<\/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> \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u00abduplicate key value violates unique constraint &#171;pg_class_relname_nsp_index&#187;\u00bb \u0432 PostgreSQL, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 \u0432 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p>\u0421\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043c\u0435\u043d \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0441\u0435\u043a\u0446\u0438\u0439, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c <a href=\"https:\/\/habr.com\/ru\/articles\/791204\/\">Postgres<\/a> \u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445, \u0434\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0432\u0443\u0445 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430, \u043d\u043e \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430, \u0441 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0439, \u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u0435\u0440\u0435, \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043a\u0446\u0438\u0435\u0439 \u043d\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435. \u0410 \u044d\u0442\u043e\u0442 exception \u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u0431\u0430\u0433\u043e\u043c Postgres. \u041d\u043e \u0434\u0430\u043b\u0435\u0435, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u0432\u043d\u043e\u0432\u044c \u0438 \u0432\u043d\u043e\u0432\u044c, \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0438, \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0438\u043c\u0435\u043d, \u0434\u043b\u0438\u043d\u043e\u0439 \u043e\u043a\u043e\u043b\u043e 30 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0430 \u044d\u0442\u043e \u0432 \u0434\u0432\u0430 \u0441 \u043b\u0438\u0448\u043d\u0438\u043c \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f Postgres \u0432 63 \u0441\u0438\u043c\u0432\u043e\u043b\u0430). \u041f\u0440\u0438\u0447\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u043c\u0435\u043b\u0430 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440: \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0441\u0442\u0435\u043d\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0434\u0430\u0447\u043d\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443, \u0430 \u043f\u0440\u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u043d\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u0442\u0435\u043d\u0434\u0435 \u0441\u0431\u043e\u0440\u043a\u0430 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439. \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435\u0437\u0430\u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 &#8212; \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0432\u043d\u0443\u0442\u0440\u0438\u043f\u0440\u043e\u0435\u043a\u0442\u043d\u043e\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043e \u043d\u0435\u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u0430 \u0434\u043b\u044f \u0438\u043c\u0435\u043d. \u041d\u043e 30 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 &#8212; \u044d\u0442\u043e \u043c\u0430\u043b\u043e. \u0412 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0432 Oracle (\u0432 \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0436\u0435 \u0441\u0442\u0430\u0440\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445), \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 30 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043c\u0435\u043d\u044f \u043b\u0438\u0447\u043d\u043e, \u0443\u0433\u043d\u0435\u0442\u0430\u043b\u043e. \u0412 \u0440\u044f\u0434\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u043d\u0435 \u0443\u0445\u0443\u0434\u0448\u0430\u044e\u0442 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 \u0435\u0435, \u0432\u043d\u043e\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f (\u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u043f\u043e \u043f\u0440\u043e\u0448\u0435\u0441\u0442\u0432\u0438\u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043f\u043e\u0434\u0431\u043e\u0440 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0437\u0430\u043d\u044f\u0442\u0438\u0435\u043c, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f. \u0418, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u0432\u044b\u0431\u0438\u0440\u0430\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u043c\u044b \u0437\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u0443 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f &#8212; \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0439 &#8212; \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u0430\u044f \u0438 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430. \u0422.\u043e. \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u0441 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043d\u044f\u043b, \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 \u043b\u0435\u0433\u0447\u0435, \u0435\u0441\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u0435\u0435, \u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c \u044d\u0442\u0438\u0445 \u0438\u043c\u0435\u043d \u0431\u044b\u043b\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 (\u0438\u043d\u0430\u0447\u0435, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 \u0438\/\u0438\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439).<\/p>\n<p>\u0414\u043b\u044f\u00a0\u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e\u00a0\u044d\u0442\u043e \u0437\u0430\u00a0unique constraint:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432 \u0438\u043c\u0435\u043d\u0430\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u044d\u0442\u043e \u043f\u043e\u043a\u0430 \u044f\u0432\u043d\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 &#8212; \u044d\u0442\u043e \u0436\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 pg_catalog.pg_class \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0411\u0414 (\u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0442\u0430\u0431\u043b\u0438\u0446):<\/p>\n<pre><code class=\"sql\">select      relkind, *  from      pg_catalog.pg_class  where      not (relkind = any('{i, I}'::char[]))<\/code><\/pre>\n<p>\u0412 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u0443\u0442\u0430\u0442\u044c \u043d\u0430\u0448\u0443: <a href=\"https:\/\/www.google.com\/search?q=duplicate+key+value+violates+unique+constraint+%22pg_type_typname_nsp_index%22&amp;sca_esv=e7a01fb2273cd8ce&amp;sxsrf=ADLYWIJmu-cnpjRphmnyzBIbGu0qBEnzVw%3A1736581602557&amp;ei=4iGCZ6fUIbSC9u8P8u_ZiA4&amp;ved=0ahUKEwinzazMlu2KAxU0gf0HHfJ3FuEQ4dUDCBA&amp;uact=5&amp;oq=duplicate+key+value+violates+unique+constraint+%22pg_type_typname_nsp_index%22&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiSmR1cGxpY2F0ZSBrZXkgdmFsdWUgdmlvbGF0ZXMgdW5pcXVlIGNvbnN0cmFpbnQgInBnX3R5cGVfdHlwbmFtZV9uc3BfaW5kZXgiSKkOUO4IWO4IcAF4AZABAJgBgwGgAYMBqgEDMC4xuAEDyAEA-AEC-AEBmAIBoAIIwgIKEAAYsAMY1gQYR5gDAIgGAZAGCJIHATGgB4AB&amp;sclient=gws-wiz-serp\">duplicate key value violates unique constraint &#171;pg_type_typname_nsp_index&#187;<\/a>, &#8212; \u043e\u043d\u0430, \u043a\u0430\u043a \u0440\u0430\u0437, \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432 \u0438\u043c\u0435\u043d\u0430\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u0438 \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c. \u041e\u043d\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 &#8212; \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u041c\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u0438\u0445 \u0438 \u0442\u0435\u0445 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u044f\u0445 &#8212; \u044d\u0442\u043e \u044f\u0432\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u0421\u0423\u0411\u0414 &#8212; \u044d\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e &#171;\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435&#187; \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 DDL \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0438\u043b\u0438 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0442\u043e\u0433\u043e middleware, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442). \u0412 \u043d\u0430\u0448\u0435\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 &#171;\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435&#187; &#8212; \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c, \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0440\u0430\u0437\u043d\u044b\u0435, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442, \u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u044f\u0445.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>the_table_with_a_really_long_descriptive_name_1<\/p>\n<\/li>\n<li>\n<p>the_table_with_a_really_long_descriptive_name_2<\/p>\n<\/li>\n<li>\n<p>the_table_with_a_really_long_descriptive_name_3<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u0430\u0436\u0434\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0438\u043d\u0434\u0435\u043a\u0441:<\/p>\n<pre><code class=\"sql\">create table     the_table_with_a_really_long_descriptive_name_1 (         key_field integer         , some_attribute integer     )     partition by          list(key_field) ;  create index i_the_table_with_a_really_long_descriptive_name_1$some_attribute      on the_table_with_a_really_long_descriptive_name_1 (         some_attribute     ) ;<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0435\u043a\u0446\u0438\u044f\u0445. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<\/p>\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 shell-\u0441\u043a\u0440\u0438\u043f\u0442 \u0441 psql, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0448\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435, \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0442\u0440\u0435\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u043a\u0436\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<pre><code class=\"bash\">#!\/bin\/bash  pg_connection_string=\"postgresql:\/\/postgres@localhost:5432\/postgres\"  function create_partitioned_table() {     echo \"         \\set ON_ERROR_STOP true         \\         drop table if exists              the_table_with_a_short_name_$1         ;                  create table             the_table_with_a_short_name_$1 (                 key_field integer                 , some_attribute integer             )             partition by                  list(key_field)         ;                  create index i_the_table_with_a_short_name_$1$some_attribute              on the_table_with_a_short_name_$1 (                 some_attribute             )         ;         \\         do \\$plsql\\$         begin             for i in 1..3 loop                 execute                     format(                         \\$dml\\$                         create table                              the_table_with_a_short_name_$1\\$partition%s                          partition of                              the_table_with_a_short_name_$1                         for values                             in (%s)                         \\$dml\\$                         , i                         , i                     )                 ;             end loop             ;         end         \\$plsql\\$         ;         \\         drop table if exists              the_table_with_a_really_long_descriptive_name_$1         ;                  create table             the_table_with_a_really_long_descriptive_name_$1 (                 key_field integer                 , some_attribute integer             )             partition by                  list(key_field)         ;                  create index i_the_table_with_a_really_long_descriptive_name_$1$some_attribute              on the_table_with_a_really_long_descriptive_name_$1 (                 some_attribute             )         ;         \\         do \\$plsql\\$         begin             for i in 1..3 loop                 execute                     format(                         \\$dml\\$                         create table                              the_table_with_a_really_long_descriptive_name_$1\\$partition%s                          partition of                              the_table_with_a_really_long_descriptive_name_$1                         for values                             in (%s)                         \\$dml\\$                         , i                         , i                     )                 ;             end loop             ;         end         \\$plsql\\$         ;     \" |     psql \\         --dbname=$pg_connection_string \\         --quiet     sleep 1 }  execute_in_parallel=\"$1\" # specify \"true\" to execute in parallel  for i in {1..3} do     if [[ $execute_in_parallel = \"true\" ]]; then          create_partitioned_table $i &amp; # execution in the background     else         create_partitioned_table $i     fi done  wait  psql \\     --dbname=$pg_connection_string \\     --command=\"\\di\"  echo \"All done\"<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a, \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b Postgres: \u0443 \u0438\u043c\u0435\u043d \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u043a\u0446\u0438\u0439, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0438\u043c\u0435\u043d\u0438 \u0441\u0435\u043a\u0446\u0438\u0438, \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0444\u0438\u043a\u0441 &#171;i_&#187;, \u0438, \u043f\u0440\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043b\u0438\u043c\u0438\u0442\u0430 \u043f\u043e \u0434\u043b\u0438\u043d\u0435 (63 \u0441\u0438\u043c\u0432\u043e\u043b\u0430), \u0432\u044b\u0440\u0435\u0437\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c (\u0433\u0434\u0435-\u0442\u043e, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u0440\u0435\u0442\u0438), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441 &#171;_idx[N]&#187;.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440), \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u043a\u043e\u043c\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 (\u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0440\u0430\u0437\u043d\u044b\u043c\u0438, \u0442.\u043a. \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c):<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u043c\u0435\u043d \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0432 \u0438\u0442\u043e\u0433\u0435, \u043d\u0435 \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u043b\u0438\u043d\u0435; \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, exception \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0438\u0437-\u0437\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0431\u0430\u0433\u0430 Postgres &#8212; \u043f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0430 \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043f\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0441\u0435\u043a\u0446\u0438\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 &#8212; \u0442.\u0435. \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0421\u0423\u0411\u0414, \u0434\u0443\u043c\u0430\u044e, \u043d\u0435\u0442. \u0415\u0449\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u0435\u043a\u0446\u0438\u0439 \u0432 \u043e\u0434\u043d\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#8212; \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c\u0438 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0434\u0432\u0443\u043c\u044f \u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, &#8212; \u0442.\u043a. \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u043a\u0446\u0438\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0435\u0434\u0438\u043d\u043e\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0441\u0435\u043a\u0446\u0438\u0438 (create table &#8230; partition of &#8230; \u0438\u043b\u0438 alter table &#8230; attach partition &#8230;), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u044b\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043b\u0435\u0436\u0438\u0442 \u0438\u0434\u0435\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442.\u043d. \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0438\u043c\u0435\u044e\u0449\u0435\u0439 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0442\u0430\u043a\u0438\u0445 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre><code class=\"sql\">create or replace view v_orderliness_logical_dependency as with      partitioned_table <\/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-444773","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444773","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=444773"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444773\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=444773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=444773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=444773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}