{"id":304885,"date":"2020-06-05T09:01:32","date_gmt":"2020-06-05T09:01:32","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304885"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-06-05T09:01:32","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304885","title":{"rendered":"\u041f\u043e\u043d\u0438\u043c\u0430\u0435\u043c \u043f\u043b\u0430\u043d\u044b PostgreSQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0435\u0449\u0435 \u0443\u0434\u043e\u0431\u043d\u0435\u0435"},"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\/505348\/\">\u041f\u043e\u043b\u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/477624\/\">\u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0438 <i><b>explain.tensor.ru<\/b><\/i><\/a> \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/explain.tensor.ru\/\">\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043b\u0430\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/a> \u043a PostgreSQL.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gx\/zv\/we\/gxzvwectsmzeqfghxmnfo9ggwz0.png\"><\/p>\n<p>  \u0417\u0430 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0435 \u043c\u0435\u0441\u044f\u0446\u044b \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u043e \u043d\u0435\u0433\u043e <a href=\"https:\/\/pgconf.ru\/2020\/262963\">\u0434\u043e\u043a\u043b\u0430\u0434 \u043d\u0430 PGConf.Russia 2020<\/a>, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043e\u0431\u043e\u0431\u0449\u0430\u044e\u0449\u0443\u044e <a href=\"https:\/\/habr.com\/ru\/post\/492694\/\">\u0441\u0442\u0430\u0442\u044c\u044e \u043f\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044e SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/a> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0432\u044b\u0434\u0430\u0435\u0442\u2026 \u043d\u043e \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438 \u0432\u0430\u0448\u0438 \u043e\u0442\u0437\u044b\u0432\u044b \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0437\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 use case.<\/p>\n<p>  \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0433\u043e\u0442\u043e\u0432\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u043f\u043b\u0430\u043d\u043e\u0432<\/h2>\n<p>  <\/p>\n<h4>\u041f\u043b\u0430\u043d \u0438\u0437 \u043b\u043e\u0433\u0430, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c<\/h4>\n<p>  \u041f\u0440\u044f\u043c\u043e \u0441 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u0432\u0435\u0441\u044c \u0431\u043b\u043e\u043a, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 <b>Query Text<\/b>, \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c\u0438:<\/p>\n<pre><code class=\"plaintext\">        Query Text: INSERT INTO  dicquery_20200604  VALUES ($1.*) ON CONFLICT (query)                            DO NOTHING;         Insert on dicquery_20200604  (cost=0.00..0.05 rows=1 width=52) (actual time=40.376..40.376 rows=0 loops=1)           Conflict Resolution: NOTHING           Conflict Arbiter Indexes: dicquery_20200604_pkey           Tuples Inserted: 1           Conflicting Tuples: 0           Buffers: shared hit=9 read=1 dirtied=1           -&gt;  Result  (cost=0.00..0.05 rows=1 width=52) (actual time=0.001..0.001 rows=1 loops=1) <\/code><\/pre>\n<p>  \u2026 \u0438 \u0437\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u043f\u043b\u0430\u043d\u0430, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rm\/fc\/du\/rmfcdu_zuzptkvhuzyjnz5lbzl4.png\"><\/p>\n<p>  \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0431\u043e\u043d\u0443\u0441\u043e\u043c \u043a \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u043b\u0430\u043d\u0443 \u0435\u0449\u0435 \u0438 <b>\u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u00ab\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u00bb<\/b>, \u0433\u0434\u0435 \u043d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432\u043e \u0432\u0441\u0435\u0439 \u043a\u0440\u0430\u0441\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oq\/l4\/xq\/oql4xqrollpcm17emnlaneqrio8.png\"><\/p>\n<h4>JSON \u0438 YAML<\/h4>\n<p>  <\/p>\n<pre><code class=\"sql\">EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) SELECT * FROM pg_class;<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"json\">&quot;[   {     &quot;Plan&quot;: {       &quot;Node Type&quot;: &quot;Seq Scan&quot;,       &quot;Parallel Aware&quot;: false,       &quot;Relation Name&quot;: &quot;pg_class&quot;,       &quot;Alias&quot;: &quot;pg_class&quot;,       &quot;Startup Cost&quot;: 0.00,       &quot;Total Cost&quot;: 1336.20,       &quot;Plan Rows&quot;: 13804,       &quot;Plan Width&quot;: 539,       &quot;Actual Startup Time&quot;: 0.006,       &quot;Actual Total Time&quot;: 1.838,       &quot;Actual Rows&quot;: 10266,       &quot;Actual Loops&quot;: 1,       &quot;Shared Hit Blocks&quot;: 646,       &quot;Shared Read Blocks&quot;: 0,       &quot;Shared Dirtied Blocks&quot;: 0,       &quot;Shared Written Blocks&quot;: 0,       &quot;Local Hit Blocks&quot;: 0,       &quot;Local Read Blocks&quot;: 0,       &quot;Local Dirtied Blocks&quot;: 0,       &quot;Local Written Blocks&quot;: 0,       &quot;Temp Read Blocks&quot;: 0,       &quot;Temp Written Blocks&quot;: 0     },     &quot;Planning Time&quot;: 5.135,     &quot;Triggers&quot;: [     ],     &quot;Execution Time&quot;: 2.389   } ]&quot;<\/code><\/pre>\n<p>  \u0425\u043e\u0442\u044c \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438, \u043a\u0430\u043a \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 pgAdmin, \u0445\u043e\u0442\u044c \u0431\u0435\u0437 \u2014 \u043a\u0438\u0434\u0430\u0435\u043c \u0432 \u0442\u043e \u0436\u0435 \u043f\u043e\u043b\u0435, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u2014 \u043a\u0440\u0430\u0441\u043e\u0442\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rv\/4k\/8s\/rv4k8sqakt72eqcs86rqe1mffv4.png\"><\/p>\n<h2>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <\/h2>\n<p>  <\/p>\n<h4>Planning Time \/ Execution Time<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043b\u0443\u0447\u0448\u0435 \u0432\u0438\u0434\u043d\u043e, \u043a\u0443\u0434\u0430 \u0443\u0448\u043b\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jc\/tu\/k0\/jctuk02m-vxqydllbwvjp9bdemy.png\"><\/p>\n<h4>I\/O Timing<\/h4>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0432\u0440\u043e\u0434\u0435 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0447\u0438\u0442\u0430\u043b\u043e\u0441\u044c-\u043f\u0438\u0441\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e, \u0430 \u0432\u0440\u043e\u0434\u0435 \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e.<\/p>\n<p>  \u0422\u0443\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c: &quot;<i>\u041e\u0439, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u0438\u0441\u043a \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u044b\u043b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0438\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u0430\u043a \u0434\u043e\u043b\u0433\u043e!<\/i>&quot; \u041d\u043e \u043a\u0430\u043a-\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0442\u043e\u0447\u043d\u043e\u2026<\/p>\n<p>  \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0440\u0435\u0434\u0438 \u043e\u043f\u0446\u0438\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 PG-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0435\u0441\u0442\u044c <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/runtime-config-statistics\"><code>track_io_timing<\/code><\/a>:  <\/p>\n<blockquote><p>\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0437\u0430\u043c\u0435\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430. \u042d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445. \u0414\u043b\u044f \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u0434\u0435\u0440\u0436\u0435\u043a \u0437\u0430\u043c\u0435\u0440\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 pg_test_timing. \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 pg_stat_database, <b>\u0432 \u0432\u044b\u0432\u043e\u0434\u0435 EXPLAIN (\u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 BUFFERS)<\/b> \u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 pg_stat_statements.<\/p><\/blockquote>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438:<\/p>\n<pre><code class=\"sql\">SET track_io_timing = TRUE;<\/code><\/pre>\n<p>  \u041d\u0443, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0435 \u2014 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0441\u0435\u0445 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0439 \u0434\u0435\u0440\u0435\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uy\/s2\/7-\/uys27-ju9ht7w_yphl3audkplre.png\"><\/p>\n<p>  \u0422\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u0437 0.790ms \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f 0.718ms \u0437\u0430\u043d\u044f\u043b\u043e \u0447\u0442\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u0430\u043d\u043d\u044b\u0445, 0.044ms \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u0435\u0435 \u0436\u0435, \u0430 \u043d\u0430 \u0432\u0441\u044e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u043b\u043e \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043e \u0432\u0441\u0435\u0433\u043e 0.028ms!<\/p>\n<h2>\u0411\u0443\u0434\u0443\u0449\u0435\u0435 \u0441 PostgreSQL 13<\/h2>\n<p>  \u041e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u043e\u0431\u0437\u043e\u0440\u043e\u043c \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/habr.com\/ru\/company\/postgrespro\/blog\/493106\/\">\u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>, \u0430 \u043c\u044b \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043f\u0440\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043f\u043b\u0430\u043d\u0430\u0445.<\/p>\n<h4>Planning buffers<\/h4>\n<p>  <\/p>\n<blockquote><p>\u0423\u0447\u0435\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0443, \u043d\u0430\u0448\u0435\u043b \u0441\u0432\u043e\u0435 \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0430\u0442\u0447\u0435, \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u043c\u0443\u0441\u044f \u043a pg_stat_statements. EXPLAIN \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 BUFFERS \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0443\u0444\u0435\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"plaintext\"> Seq Scan on pg_class (actual rows=386 loops=1)    Buffers: shared hit=9 read=4  Planning Time: 0.782 ms    Buffers: shared hit=103 read=11  Execution Time: 0.219 ms<\/code><\/pre>\n<\/blockquote>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7j\/pb\/qo\/7jpbqorwrndrx9dghs8ppab-eg4.png\"><\/p>\n<h4>\u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430<\/h4>\n<p>  <\/p>\n<blockquote><p>\u0412 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u043c\u043d\u043e\u0433\u0438\u043c \u043a\u043b\u044e\u0447\u0430\u043c (k1, k2, k3\u2026), \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u043d\u0438\u0435\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0438\u0437 \u043f\u0435\u0440\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, k1 \u0438 k2). \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043d\u043e\u0432\u043e, \u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 k1 \u0438 k2, \u0438 \u201c\u0434\u043e\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u201d \u043f\u043e \u043a\u043b\u044e\u0447\u0443 k3.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u0441\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0440\u0430\u0441\u043f\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043e\u043a \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430. \u042d\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0435\u0449\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0432\u0441\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<pre><code class=\"plaintext\"> Incremental Sort (actual rows=2949857 loops=1)    Sort Key: ticket_no, passenger_id    Presorted Key: ticket_no    Full-sort Groups: 92184 Sort Method: quicksort Memory: avg=31kB peak=31kB    -&gt;  Index Scan using tickets_pkey on tickets (actual rows=2949857 loops=1)  Planning Time: 2.137 ms  Execution Time: 2230.019 ms<\/code><\/pre>\n<\/blockquote>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nf\/bk\/4e\/nfbk4ee5vsbmyl0grg5t_d0a4t0.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/4f\/ms\/l8\/4fmsl8zcwmnnq6iwvlykftvsi4k.png\"><\/p>\n<h2>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f UI\/UX<\/h2>\n<p>  <\/p>\n<h4>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b, \u043e\u043d\u0438 \u0432\u0435\u0437\u0434\u0435!<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u043a\u043b\u0430\u0434\u043a\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e <b>\u0432\u0437\u044f\u0442\u044c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0432\u043a\u043b\u0430\u0434\u043a\u0438 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430<\/b> \u043d\u0430 \u0432\u0441\u044e \u0448\u0438\u0440\u0438\u043d\u0443 \u0438 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0432\u043a\u043b\u0430\u0434\u043a\u0438 \u2014 <b>\u00ab\u043f\u0440\u0438\u0446\u0435\u043b\u00bb \u0441\u043f\u0440\u0430\u0432\u0430-\u0441\u0432\u0435\u0440\u0445\u0443<\/b>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ob\/fj\/uz\/obfjuzeg2n1rwo9-wkpyhsvtop4.png\"><\/p>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a.<\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043d\u0430 \u0443\u0437\u043b\u0430\u0445<\/h4>\n<p>  \u0418\u0445 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u043e \u0438 \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u0443\u044e \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/habr.com\/ru\/post\/492694\/\">\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ml\/mz\/l2\/mlmzl2_njzqsdh9d48gfori5ho8.png\"><\/p>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 \u0430\u0440\u0445\u0438\u0432\u0430<\/h4>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <b>\u0443\u0434\u0430\u043b\u044f\u0442\u044c \u00ab\u0441\u043e\u0432\u0441\u0435\u043c\u00bb<\/b> \u0434\u0430\u0436\u0435 \u043d\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c\u044b\u0435 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u043f\u043b\u0430\u043d\u044b \u2014 \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0438\u043a\u043e\u043d\u043a\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/4f\/go\/lr\/4fgolro-qyewla9y-6glatsgopu.png\"><\/p>\n<p>  \u041d\u0443, \u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c <a href=\"https:\/\/n.sbis.ru\/explain\/forum\/\">\u0433\u0440\u0443\u043f\u043f\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438<\/a>, \u043a\u0443\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/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\/505348\/\"> https:\/\/habr.com\/ru\/company\/tensor\/blog\/505348\/<\/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\/505348\/\">\u041f\u043e\u043b\u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/477624\/\">\u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0438 <i><b>explain.tensor.ru<\/b><\/i><\/a> \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/explain.tensor.ru\/\">\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043b\u0430\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/a> \u043a PostgreSQL.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gx\/zv\/we\/gxzvwectsmzeqfghxmnfo9ggwz0.png\"><\/p>\n<p>  \u0417\u0430 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0435 \u043c\u0435\u0441\u044f\u0446\u044b \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u043e \u043d\u0435\u0433\u043e <a href=\"https:\/\/pgconf.ru\/2020\/262963\">\u0434\u043e\u043a\u043b\u0430\u0434 \u043d\u0430 PGConf.Russia 2020<\/a>, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043e\u0431\u043e\u0431\u0449\u0430\u044e\u0449\u0443\u044e <a href=\"https:\/\/habr.com\/ru\/post\/492694\/\">\u0441\u0442\u0430\u0442\u044c\u044e \u043f\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044e SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/a> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0432\u044b\u0434\u0430\u0435\u0442\u2026 \u043d\u043e \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438 \u0432\u0430\u0448\u0438 \u043e\u0442\u0437\u044b\u0432\u044b \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0437\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 use case.<\/p>\n<p>  \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0433\u043e\u0442\u043e\u0432\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.  <\/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-304885","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304885","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=304885"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304885\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}