{"id":301796,"date":"2020-04-13T21:00:34","date_gmt":"2020-04-13T21:00:34","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301796"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-04-13T21:00:34","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301796","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c \u0432 PostgreSQL \u043d\u0430 \u0441\u0443\u0431\u0441\u0432\u0435\u0442\u043e\u0432\u043e\u0439: 1 host, 1 day, 1TB"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/497008\/\">\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0440\u0435\u0446\u0435\u043f\u0442\u043e\u0432 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/492694\/\">\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u00ab\u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435\u00bb<\/a> \u0438\u0437 PostgreSQL-\u0431\u0430\u0437\u044b. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0436\u0435 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a <b>\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c<\/b> \u0432 \u0411\u0414 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u00ab\u043a\u0440\u0443\u0442\u0438\u043b\u043e\u043a\u00bb \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0432 \u043f\u043e\u0442\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lv\/ir\/or\/lvirorsnhddruod1aggj8x4fgei.png\"><\/div>\n<p>  <\/p>\n<h2>#1. \u0421\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0438 \u0437\u0430\u0447\u0435\u043c \u0441\u0442\u043e\u0438\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/483170\/\">\u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0435 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u00ab\u0432 \u0442\u0435\u043e\u0440\u0438\u0438\u00bb<\/a> \u0443\u0436\u0435 \u0431\u044b\u043b\u0430, \u0437\u0434\u0435\u0441\u044c \u0436\u0435 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e <a href=\"https:\/\/habr.com\/ru\/post\/487380\/\">\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0442\u0435\u043d PostgreSQL-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432<\/a>.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u00ab\u0414\u0435\u043b\u0430 \u0434\u0430\u0432\u043d\u043e \u043c\u0438\u043d\u0443\u0432\u0448\u0438\u0445 \u0434\u043d\u0435\u0439&#8230;\u00bb<\/h4>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e, \u043a\u0430\u043a \u0438 \u0432\u0441\u044f\u043a\u0438\u0439 MVP, \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b \u043f\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u2014 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u0435\u0441\u044f\u0442\u043a\u0430 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0432\u0441\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u044b\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u2026 \u041d\u043e \u0432\u0440\u0435\u043c\u044f \u0448\u043b\u043e, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0445\u043e\u0441\u0442\u043e\u0432 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0432\u0448\u0438\u0441\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 <b>\u0442\u0430\u0431\u043b\u0438\u0446 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 1.5TB<\/b>, \u043c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u0436\u0438\u0442\u044c \u0442\u0430\u043a \u0434\u0430\u043b\u044c\u0448\u0435 \u0445\u043e\u0442\u044c \u0438 \u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0436 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>  \u0412\u0440\u0435\u043c\u0435\u043d\u0430 \u0431\u044b\u043b\u0438 \u043f\u043e\u0447\u0442\u0438 \u0447\u0442\u043e \u0431\u044b\u043b\u0438\u043d\u043d\u044b\u0435, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0431\u044b\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b PostgreSQL 9.x, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u00ab\u0432\u0440\u0443\u0447\u043d\u0443\u044e\u00bb \u2014 \u0447\u0435\u0440\u0435\u0437 <b>\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b<\/b> \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430 \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c <code>EXECUTE<\/code>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tt\/-k\/sv\/tt-ksvme0jrmkz2qzkh8va95pjs.png\"><\/div>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0432\u0441\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<ul>\n<li>\u0411\u044b\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u043f\u0443\u0441\u0442\u0430\u044f \u00ab\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u0430\u044f\u00bb \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0432\u0441\u0435 <b>\u043d\u0443\u0436\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b<\/b>.<\/li>\n<li>\u0417\u0430\u043f\u0438\u0441\u044c \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0432 \u00ab\u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e\u00bb \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>\u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430 \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430<\/b> <code>BEFORE INSERT<\/code> \u0437\u0430\u043f\u0438\u0441\u044c \u00ab\u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u00bb \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0435\u0449\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u2014 \u043c\u044b \u043b\u043e\u0432\u0438\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 &#8230;<\/li>\n<li>\u2026 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/post\/492464\/\"><code>CREATE TABLE ... (LIKE ... INCLUDING ...)<\/code><\/a> \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0430\u0441\u044c <b>\u0441\u0435\u043a\u0446\u0438\u044f \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u043d\u0443\u0436\u043d\u0443\u044e \u0434\u0430\u0442\u0443<\/b>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043d\u0435\u0439.<\/li>\n<\/ul>\n<p>  <\/p>\n<h4>PG10: \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h4>\n<p>  \u041d\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u0435\u043a\u0446\u0438\u0439-\u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0431\u043e\u0440\u0430 \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u0438\u043c\u0435\u043b <b>\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c<\/b>, \u0447\u0442\u043e \u043f\u0440\u0438 100+ \u0441\u0435\u043a\u0446\u0438\u044f\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0441\u0430\u043c\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u2026<\/p>\n<p>  \u0412 PG10 \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/10\/ddl-partitioning\">\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0441\u0445\u043e\u0434\u0443 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043d\u043e\u2026<\/p>\n<p>  \u041a\u0430\u043a \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u0430\u043f\u044b\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u043d\u0443\u0430\u043b\u0430, \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438:<\/p>\n<ul>\n<li>\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/li>\n<li>\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0430 \u043d\u0435\u0439 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u0432<\/li>\n<li>\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u0430 \u043d\u0438\u0447\u044c\u0438\u043c \u00ab\u043f\u043e\u0442\u043e\u043c\u043a\u043e\u043c\u00bb<\/li>\n<li>\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <code>INSERT ... ON CONFLICT<\/code><\/li>\n<li>\u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438<\/li>\n<\/ul>\n<p>  \u0411\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u043f\u043e \u043b\u0431\u0443 \u0433\u0440\u0430\u0431\u043b\u044f\u043c\u0438, \u043c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u0431\u0435\u0437 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043d\u0435 \u0443\u0434\u0430\u0441\u0442\u0441\u044f, \u0438 \u043e\u0442\u043b\u043e\u0436\u0438\u043b\u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u043b\u0433\u043e\u0434\u0430.<\/p>\n<h4>PG10: \u0432\u0442\u043e\u0440\u043e\u0439 \u0448\u0430\u043d\u0441<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438:<\/p>\n<ol>\n<li>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u044b \u0438 <code>ON CONFLICT<\/code> \u043d\u0430\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043a\u043e\u0435-\u0433\u0434\u0435 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043d\u0443\u0436\u043d\u044b, \u0434\u043b\u044f \u0438\u0445 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0443\u044e <b>\u043f\u0440\u043e\u043a\u0441\u0438-\u0442\u0430\u0431\u043b\u0438\u0446\u0443<\/b>.<\/li>\n<li><b>\u0418\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u00ab\u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430\u00bb<\/b> \u0432 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430\u0445 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442 <code>EXECUTE<\/code>.<\/li>\n<li>\u0412\u044b\u043d\u0435\u0441\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e <b>\u0442\u0430\u0431\u043b\u0438\u0446\u0443-\u0448\u0430\u0431\u043b\u043e\u043d \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438<\/b>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u043a\u0441\u0438-\u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/li>\n<\/ol>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sn\/3h\/ra\/sn3hrac9yg0-hrifkjszy7fhih0.png\"><\/div>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e, \u0443\u0436\u0435 \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u0442\u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u043f\u043e\u043a\u0430 \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0441\u043e\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h4>\u00ab\u041f\u0438\u043b\u0438\u043c\u00bb \u0441\u043b\u043e\u0432\u0430\u0440\u0438<\/h4>\n<p>  \u041a\u0430\u043a \u0438 \u0432 \u043b\u044e\u0431\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0443 \u043d\u0430\u0441 \u0442\u043e\u0436\u0435 \u0431\u044b\u043b\u0438 <b>\u00ab\u0444\u0430\u043a\u0442\u044b\u00bb \u0438 \u00ab\u0440\u0430\u0437\u0440\u0435\u0437\u044b\u00bb<\/b> (\u0441\u043b\u043e\u0432\u0430\u0440\u0438). \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432 \u044d\u0442\u043e\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/youtu.be\/5XKbFb-l5Do?t=2487\">\u0442\u0435\u043b\u043e \u00ab\u0448\u0430\u0431\u043b\u043e\u043d\u0430\u00bb<\/a> \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>  \u00ab\u0424\u0430\u043a\u0442\u044b\u00bb \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u0438 \u043e\u0442\u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e \u0434\u043d\u044f\u043c \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0443\u0434\u0430\u043b\u044f\u043b\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0438, \u0438 \u043e\u043d\u0438 \u043d\u0430\u043c \u043d\u0435 \u043c\u0435\u0448\u0430\u043b\u0438 (\u043b\u043e\u0433\u0438 \u0436\u0435!). \u0410 \u0432\u043e\u0442 \u0441\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0431\u0435\u0434\u0430\u2026<\/p>\n<p>  \u041d\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u0445 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e <b>\u043d\u0430 100TB \u00ab\u0444\u0430\u043a\u0442\u043e\u0432\u00bb \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043d\u0430 2.5TB<\/b>. \u0418\u0437 \u0442\u0430\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0443\u0434\u0430\u043b\u044f\u0435\u0448\u044c, \u043d\u0435 \u0441\u043e\u0436\u043c\u0435\u0448\u044c \u0437\u0430 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0434\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043d\u0435\u0435 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u0441\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435.<\/p>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044c\u2026 \u0432 \u043d\u0435\u043c \u043a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437\u2026 \u0438 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043d\u043e!.. \u041d\u0438\u043a\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043c \u0438\u043c\u0435\u0442\u044c <b>\u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0430\u0440\u044e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c<\/b>! \u0414\u0430, \u044d\u0442\u043e \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0437\u0430\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n<ul>\n<li><b>\u043f\u0438\u0441\u0430\u0442\u044c\/\u0447\u0438\u0442\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435<\/b> \u0437\u0430 \u0441\u0447\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u0435\u043a\u0446\u0438\u0438<\/li>\n<li><b>\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438<\/b> \u0437\u0430 \u0441\u0447\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438<\/li>\n<li><b>\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/b> \u0437\u0430 \u0441\u0447\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445<\/li>\n<\/ul>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0441\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u0430 \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u0439 <b>\u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u043e CPU \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u043d\u0430 ~30%, \u043f\u043e \u0434\u0438\u0441\u043a\u0443 \u2014 \u043d\u0430 ~50%<\/b>:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/re\/uf\/x0\/reufx0_4pxhj6cci456x4eb6j8q.png\"><\/div>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0431\u0430\u0437\u0443 \u0440\u043e\u0432\u043d\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u0441 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439.<\/p>\n<h2>#2. \u042d\u0432\u043e\u043b\u044e\u0446\u0438\u044f \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0411\u0414<\/h2>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 <b>\u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f \u0441\u0435\u043a\u0446\u0438\u044f<\/b> \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, <code>CHECK (dt = '2018-10-12'::date)<\/code> \u2014 \u0438 \u0435\u0441\u0442\u044c \u043a\u043b\u044e\u0447 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u043e\u0442\u0447\u0435\u0442\u044b \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0441\u0442\u0440\u043e\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0434\u0430\u0442\u044b, \u0442\u043e \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0435\u0449\u0435 \u0441 \u00ab\u043d\u0435\u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u00bb \u0434\u043b\u044f \u043d\u0438\u0445 \u0431\u044b\u043b\u0438 \u0432\u0441\u0435 \u0442\u0438\u043f\u0430 <i>(\u0421\u0435\u0440\u0432\u0435\u0440, <b>\u0414\u0430\u0442\u0430<\/b>, \u0428\u0430\u0431\u043b\u043e\u043d \u043f\u043b\u0430\u043d\u0430)<\/i>, <i>(\u0421\u0435\u0440\u0432\u0435\u0440, <b>\u0414\u0430\u0442\u0430<\/b>, \u0423\u0437\u0435\u043b \u043f\u043b\u0430\u043d\u0430)<\/i>, <i>(<b>\u0414\u0430\u0442\u0430<\/b>, \u041a\u043b\u0430\u0441\u0441 \u043e\u0448\u0438\u0431\u043a\u0438, \u0421\u0435\u0440\u0432\u0435\u0440)<\/i>,\u2026<\/p>\n<p>  \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u0436\u0438\u0432\u0443\u0442 <u>\u0441\u0432\u043e\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b<\/u> \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u2026 \u0418 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 <u>\u0434\u0430\u0442\u0430 \u2014 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430<\/u>\u2026 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 <b>\u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443<\/b> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043f\u043e\u043b\u0435\u0439, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043c, \u0438 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043d\u0435\u043c\u0443, \u043d\u043e \u043d\u0435 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0421\u0430\u043c\u0438 \u0441\u0435\u0431\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0433\u0440\u0430\u0431\u043b\u0438, \u0443\u043f\u0441\u2026<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rv\/to\/de\/rvtodengrwqlkufq8ovxlp71xn4.jpeg\"><\/div>\n<p>  \u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u2014 \u043f\u0440\u043e\u0441\u0442\u043e <b>\u0443\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e\u043b\u0435 \u0441 \u0434\u0430\u0442\u043e\u0439 \u0438\u0437 \u0432\u0441\u0435\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/b> \u043d\u0430 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445. \u041f\u0440\u0438 \u043d\u0430\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u2014 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 <b>1TB\/\u043d\u0435\u0434\u0435\u043b\u044e<\/b>!<\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0442\u0435\u0440\u0430\u0431\u0430\u0439\u0442 \u0435\u0449\u0435 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u043a\u0430\u043a-\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c. \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0435\u0449\u0435 \u0438 <b>\u0434\u0438\u0441\u043a \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435<\/b>! \u041d\u0430 \u044d\u0442\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0438\u0434\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442, \u043e\u0442 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0447\u0438\u0441\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043f\u043e\u0441\u0432\u044f\u0442\u0438\u043b\u0438 \u043d\u0435\u0434\u0435\u043b\u044e:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/x0\/4d\/dv\/x04ddvnrw9ga5m5gt4fukn44vza.png\"><\/p>\n<h2>#3. \u00ab\u0420\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u00bb \u043f\u0438\u043a\u043e\u0432\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443<\/h2>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0431\u0435\u0434 \u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u2014 \u044d\u0442\u043e <b>\u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f<\/b> \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0442\u043e\u0433\u043e \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0445. \u0418\u043d\u043e\u0433\u0434\u0430 \u00ab\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438\u00bb, \u0438\u043d\u043e\u0433\u0434\u0430 \u00ab\u0442\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435\u00bb, \u043d\u043e \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0442 \u043d\u0435\u0435 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u041f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u2014 \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0434\u0438\u0441\u043a \u0443 \u043d\u0430\u0441 <b>\u00ab\u043a\u0430\u0447\u0430\u0435\u0442\u00bb \u043f\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0441 \u0434\u0432\u0443\u043a\u0440\u0430\u0442\u043d\u043e\u0439 \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u043e\u0439<\/b> \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u043e\u0442\u0441\u0447\u0435\u0442\u0430\u043c\u0438, \u0447\u0435\u0433\u043e \u044f\u0432\u043d\u043e \u00ab\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u00bb \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p4\/9v\/bw\/p49vbwkzasfbjhcnudcmsqaxgaq.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u0423 \u043d\u0430\u0441 \u043d\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0431\u044b\u043b\u043e \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u043e \u0443\u0436\u0435 <b>\u043f\u043e\u0447\u0442\u0438 1000 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432<\/b>, \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c, \u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0432 \u0431\u0430\u0437\u0443 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">setInterval(sendToDB, interval)<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0442\u0443\u0442 \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <b>\u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u043e\u0434\u043d\u043e \u0432\u0440\u0435\u043c\u044f<\/b>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443 \u043d\u0438\u0445 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u00ab\u0434\u043e \u0442\u043e\u0447\u043a\u0438\u00bb. \u0423\u043f\u0441 \u21162\u2026<\/p>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0435\u0433\u043a\u043e, <b>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u00ab\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439\u00bb \u0440\u0430\u0437\u0431\u0435\u0436\u043a\u0438<\/b> \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438:<\/p>\n<pre><code class=\"javascript\">setInterval(sendToDB, interval * (1 + 0.1 * (Math.random() - 0.5)))<\/code><\/pre>\n<p>  <\/p>\n<h2>#4. \u041a\u044d\u0448\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e <s>\u043d\u0443\u0436\u043d\u043e<\/s> \u043c\u043e\u0436\u043d\u043e<\/h2>\n<p>  \u0422\u0440\u0435\u0442\u044c\u044f \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 highload \u2014 <b>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u044d\u0448\u0430<\/b> \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u043d <i>\u043c\u043e\u0433 \u0431\u044b<\/i> \u0431\u044b\u0442\u044c.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u0443\u0437\u043b\u043e\u0432 \u043f\u043b\u0430\u043d\u0430 (\u0432\u0441\u0435 \u044d\u0442\u0438 <code>Seq Scan on users<\/code>), \u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0438, \u0432 \u043c\u0430\u0441\u0441\u0435, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u2014 \u0437\u0430\u0431\u044b\u043b\u0438.<\/p>\n<p>  \u041d\u0435\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u0431\u0430\u0437\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043d\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u043e\u0442\u0441\u0435\u043a\u0430\u0435\u0442 \u0442\u0440\u0438\u0433\u0433\u0435\u0440 \u0441 <code>INSERT ... ON CONFLICT DO NOTHING<\/code>. \u041d\u043e \u0434\u043e \u0431\u0430\u0437\u044b-\u0442\u043e \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0435\u0442\u0430\u044e\u0442 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e, \u0434\u0430 \u0435\u0449\u0435 \u0438 \u043b\u0438\u0448\u043d\u0435\u0435 <b>\u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0430<\/b> \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f. \u0423\u043f\u0441 \u21163\u2026<\/p>\n<p>  \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0432 \u0431\u0430\u0437\u0443 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u043e\/\u043f\u043e\u0441\u043b\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nu\/ed\/jm\/nuedjmsij1za8mx-dhkcvg36baw.png\"><\/p>\n<p>  \u0410 \u044d\u0442\u043e \u2014 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oc\/bx\/hz\/ocbxhzmmplggqzowyekkkl2lsk0.png\"><\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>  \u00ab\u0422\u0435\u0440\u0430\u0431\u0430\u0439\u0442-\u0432-\u0441\u0443\u0442\u043a\u0438\u00bb \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u0441\u0442\u0440\u0430\u0448\u043d\u043e. \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c <b>2^40 \u0431\u0430\u0439\u0442 \/ 86400 \u0441\u0435\u043a\u0443\u043d\u0434 = ~12.5MB\/s<\/b>, \u0447\u0442\u043e \u0434\u0435\u0440\u0436\u0430\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u0435 IDE-\u0432\u0438\u043d\u0442\u044b. \ud83d\ude42<\/p>\n<p>  \u0410 \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e, \u0442\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0434\u0435\u0441\u044f\u0442\u0438\u043a\u0440\u0430\u0442\u043d\u043e\u043c \u00ab\u043f\u0435\u0440\u0435\u043a\u043e\u0441\u0435\u00bb \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u0443\u0442\u043e\u043a, \u0432\u044b \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043b\u043e\u0436\u0438\u0442\u044c\u0441\u044f \u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 SSD.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/in\/7l\/e5\/in7le5modvgype2possbfitaqxy.jpeg\"><\/div>\n<p> \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\/company\/tensor\/blog\/497008\/\"> https:\/\/habr.com\/ru\/company\/tensor\/blog\/497008\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/497008\/\">\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0440\u0435\u0446\u0435\u043f\u0442\u043e\u0432 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/492694\/\">\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u00ab\u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435\u00bb<\/a> \u0438\u0437 PostgreSQL-\u0431\u0430\u0437\u044b. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0436\u0435 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a <b>\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c<\/b> \u0432 \u0411\u0414 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u00ab\u043a\u0440\u0443\u0442\u0438\u043b\u043e\u043a\u00bb \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0432 \u043f\u043e\u0442\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lv\/ir\/or\/lvirorsnhddruod1aggj8x4fgei.png\"><\/div>\n<p>  <\/p>\n<h2>#1. \u0421\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0438 \u0437\u0430\u0447\u0435\u043c \u0441\u0442\u043e\u0438\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/483170\/\">\u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0435 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u00ab\u0432 \u0442\u0435\u043e\u0440\u0438\u0438\u00bb<\/a> \u0443\u0436\u0435 \u0431\u044b\u043b\u0430, \u0437\u0434\u0435\u0441\u044c \u0436\u0435 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e <a href=\"https:\/\/habr.com\/ru\/post\/487380\/\">\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0442\u0435\u043d PostgreSQL-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432<\/a>.  <\/p>\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-301796","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301796","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=301796"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301796\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}