{"id":405907,"date":"2024-06-29T18:35:50","date_gmt":"2024-06-29T18:35:50","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=405907"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=405907","title":{"rendered":"<span>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0443\u0435\u043c \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u043f\u043b\u0430\u043d\u043e\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>\u041a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u0441\u0430\u043c\u044b\u0435 &#171;\u0433\u043e\u0440\u044f\u0447\u0438\u0435&#187; \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0432\u0430\u0448\u0435\u043c PostgreSQL-\u0441\u0435\u0440\u0432\u0435\u0440\u0435? \u041f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u0438\u0445 \u0432 \u043b\u043e\u0433\u0435 \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u043d \u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/pgstatstatements\">pg_stat_statements<\/a>.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0432 \u043b\u043e\u0433 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0437\u0430 \u0441\u0443\u0442\u043a\u0438?.. \u0422\u043e\u0433\u0434\u0430 \u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043b\u0438\u043c\u0438\u0442\u0430 <code>pg_stat_statements.max<\/code> \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0435\u043b\u0438\u043a\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0434\u0438\u0432\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443. \u0422\u0430\u043a \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u0440\u044f\u043c\u043e \u0441 \u043f\u043b\u0430\u043d\u043e\u0432!<\/p>\n<p>\u041d\u043e \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 <a href=\"https:\/\/sbis.ru\/all_services\">\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0421\u0411\u0418\u0421<\/a> \u043d\u0430\u043c \u0432 <a href=\"https:\/\/tensor.ru\/\">&#171;\u0422\u0435\u043d\u0437\u043e\u0440\u0435&#187;<\/a> \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u0430, \u0447\u0442\u043e <code>auto_explain.log_min_duration<\/code> \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 <strong>\u0435\u0434\u0438\u043d\u0438\u0446\u044b \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434<\/strong> &#8212; \u0438 \u0432\u043e\u0442 \u043e\u043d\u0438, \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u043f\u043b\u0430\u043d\u043e\u0432&#8230; \u041a\u0430\u043a \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u0438\u0445?<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b96\/949\/ca2\/b96949ca2a7d38a947ba6b30c78304dc.jpeg\" width=\"568\" height=\"371\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b96\/949\/ca2\/b96949ca2a7d38a947ba6b30c78304dc.jpeg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u041e\u0442 \u043f\u043b\u0430\u043d\u043e\u0432 &#8212; \u043a \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tst AS SELECT   * , CASE     WHEN r &lt; 0.9    THEN 0     WHEN r &lt; 0.99   THEN 1     WHEN r &lt; 0.999  THEN 2     WHEN r &lt; 0.9999 THEN 3   END v FROM   (     SELECT       i     , random() r     FROM       generate_series(1, 1e4) i   ) T;  CREATE INDEX ON tst(v); ANALYZE tst;<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u043b\u0430\u043d \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0438 <code>v = 0<\/code>:<\/p>\n<pre><code class=\"sql\">EXPLAIN (ANALYZE, BUFFERS, COSTS OFF) SELECT   * FROM   tst WHERE   v = 0;<\/code><\/pre>\n<pre><code>Seq Scan on tst (actual time=0.023..1.236 rows=9034 loops=1)   Filter: (v = 0)   Rows Removed by Filter: 966   Buffers: shared hit=64<\/code><\/pre>\n<p>&#8230; <code>v = 1<\/code>:<\/p>\n<pre><code>Bitmap Heap Scan on tst (actual time=0.074..0.286 rows=876 loops=1)   Recheck Cond: (v = 1)   Heap Blocks: exact=64   Buffers: shared hit=69   ->  Bitmap Index Scan on tst_v_idx (actual time=0.058..0.058 rows=876 loops=1)         Index Cond: (v = 1)         Buffers: shared hit=5<\/code><\/pre>\n<p>&#8230; <code>v = 2<\/code>:<\/p>\n<pre><code>Bitmap Heap Scan on tst (actual time=0.047..0.106 rows=83 loops=1)   Recheck Cond: (v = 2)   Heap Blocks: exact=45   Buffers: shared hit=47   ->  Bitmap Index Scan on tst_v_idx (actual time=0.031..0.031 rows=83 loops=1)         Index Cond: (v = 2)         Buffers: shared hit=2<\/code><\/pre>\n<p>\u0438 <code>v = 3<\/code>, \u043d\u0430\u043a\u043e\u043d\u0435\u0446:<\/p>\n<pre><code>Index Scan using tst_v_idx on tst (actual time=0.020..0.026 rows=6 loops=1)   Index Cond: (v = 3)   Buffers: shared hit=8<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u043b\u0430\u043d\u043e\u0432 \u043e\u0442 &#171;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439&#187; \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u0440\u043e\u0434\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <strong>&#171;\u0448\u0430\u0431\u043b\u043e\u043d&#187; \u043f\u043b\u0430\u043d\u0430<\/strong> &#8212; \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code>-- v = 0 Seq Scan on tst<\/code><\/pre>\n<pre><code>-- v = 1, v = 2 Bitmap Heap Scan on tst   ->  Bitmap Index Scan on tst_v_idx<\/code><\/pre>\n<pre><code>-- v = 3 Index Scan using tst_v_idx on tst<\/code><\/pre>\n<p>\u0420\u043e\u0432\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438 <a href=\"https:\/\/explain.tensor.ru\/\">\u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043b\u0430\u043d\u043e\u0432<\/a>, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432\u0430\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e1e\/cf5\/dee\/e1ecf5dee82b841fcdfd194273e75f17.png\" width=\"558\" height=\"175\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e1e\/cf5\/dee\/e1ecf5dee82b841fcdfd194273e75f17.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0430\u044f \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u043f\u043b\u0430\u043d\u043e\u0432 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0432 \u0441\u043e\u0442\u043d\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432.<\/p>\n<h2>\u041e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 &#8212; \u043a \u043c\u043e\u0434\u0435\u043b\u044f\u043c<\/h2>\n<p>\u041d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b <strong>\u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441<\/strong> &#171;\u043d\u0430 \u0432\u0445\u043e\u0434\u0435&#187;, \u0430 &#171;\u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435&#187; \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0430\u0436 <strong>3 \u0440\u0430\u0437\u043d\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u0430<\/strong>! \u0418 \u0435\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0432\u043e\u0434\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e &#171;\u0442\u043e\u043f\u043e\u0432\u044b\u043c&#187; \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0443\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u0432\u0435\u0434\u044c \u0435\u0433\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 &#171;\u0440\u0430\u0437\u043c\u0430\u0437\u0430\u043d\u044b&#187; \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u044f\u043c.<\/p>\n<p>\u041d\u043e \u0432\u0435\u0434\u044c, \u0432\u043e \u0432\u0441\u0435\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>tst<\/code>, \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438: <code>Seq Scan<\/code>, <code>Bitmap Scan<\/code> \u0438 <code>Index Scan<\/code> &#8212; \u0438 \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d &#171;\u0440\u0430\u0437\u0431\u0435\u0433\u0430\u043d\u0438\u044f&#187; \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0430 \u0438\u0445 \u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u00a0\u0432\u0438\u0434 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u00a0(<code>Nested Loop<\/code>, <code>Hash Semi Join<\/code>, <code>Merge Join<\/code>, &#8230;)<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u043b\u0438\u0447\u0438\u0435\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435\/\u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0430\u043b\u0438\u0430\u0441\u043e\u0432\u00a0\u0443 \u043e\u0434\u043d\u0438\u0445 \u0438 \u0442\u0435\u0445 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0447\u0442\u0435\u043d\u0438\u0439\u00a0(<code>Index Only Scan<\/code> \/ <code>Index Scan<\/code> \/ <code>Bitmap Index Scan<\/code>) \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u00a0\u043f\u0440\u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (<code>Seq Scan<\/code> vs <code>Parallel Seq Scan<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u043b\u0438\u0447\u0438\u0435\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439\u00a0\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \/ \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \/ \u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u00a0\u0434\u043b\u044f <code>WindowAgg<\/code><\/p>\n<\/li>\n<li>\n<p>\u0441\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u00a0\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u0432, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e <strong>\u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043b\u0430\u043d\u0430<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0438 \u0431\u044b (\u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e) \u0432\u0441\u0435 \u043f\u043b\u0430\u043d\u044b \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u043b\u0430\u043d\u0430\u00a0(<code>CTE \/ InitPlan \/ SubPlan \/ Append<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0432 <code>Scan Table<\/code><\/p>\n<\/li>\n<li>\n<p>\u0432\u043c\u0435\u0441\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 <code>Join\/Loop<\/code>-\u0443\u0437\u043b\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0434\u0438\u043d <code>Join<\/code> \u0441\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0437\u043b\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0440\u043e\u0434\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u043e\u0431\u0449\u0438\u0439 \u0443\u0437\u0435\u043b <code>Process<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u0434 \u043d\u0430\u0448\u0438\u043c\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u0435\u0434\u0438\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code>Scan Table tst<\/code><\/pre>\n<p>\u0415\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/940af12543268372e8dc426cc516080d:0:2021-09-13#domain\">\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0432\u043a\u043b\u0430\u0434\u043a\u0435<\/a> \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043b\u0430\u043d\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d \u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/315\/8b4\/7c3\/3158b47c37514e471eece49706c4deec.png\" width=\"978\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/315\/8b4\/7c3\/3158b47c37514e471eece49706c4deec.png\"\/><figcaption><\/figcaption><\/figure>\n<p>&#8230; \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>Process   InitPlan 1     ->  Process           ->  Scan Table \"request-statuses\"   InitPlan 2     ->  Process           ->  Scan Table \"request-statuses\"   ->  Join         ->  Scan Table \"request-statuses\"         ->  Scan Table \"task-tracker-times\"         ->  Scan Table requests         ->  Scan Table tasks<\/code><\/pre>\n<p>\u0421\u043e\u0442\u043d\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0443\u0436\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<h2>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u043b\u0430\u043d\u043e\u0432<\/h2>\n<p>\u041d\u043e \u0441\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0434\u043b\u044f &#171;\u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445&#187; \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0427\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code>->  Scan Table tst         | A       ->  InitPlan 1       | B             -> Scan Values | B<\/code><\/pre>\n<pre><code>->  Scan Table tst         | A       SubPlan 1            | C         ->  Scan Table tst | C<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0443 &#171;\u043f\u043e\u0445\u043e\u0436\u0435\u0441\u0442\u0438&#187; \u0434\u0432\u0443\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439? \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0437\u0443\u0431\u043e\u0434\u0440\u043e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443, \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438, \u0441\u0443\u043f\u0435\u0440\u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b&#8230;<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/84b\/40f\/f3b\/84b40ff3bf2d7b3519937770cefb9028.jpg\" width=\"700\" height=\"397\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/84b\/40f\/f3b\/84b40ff3bf2d7b3519937770cefb9028.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0443 \u043e\u0431\u0435\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e \u043e\u0431\u0449\u0438\u0439 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <code>A<\/code> . \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 <code>B<\/code> \u0438 <code>C<\/code> \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u0430\u043c\u0438 \u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u043a \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0443\u0437\u043b\u0430 \u0432 \u0442\u0430\u043a\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438 \u043f\u043e\u0438\u0441\u043a \u043d\u0443\u0436\u043d\u043e\u0439 \u0438\u0433\u043e\u043b\u043a\u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u0433\u0435 \u0441\u0435\u043d\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/be0\/5c6\/26e\/be05c626ec9a13dce672f5f1900bd448.png\" width=\"892\" height=\"723\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/be0\/5c6\/26e\/be05c626ec9a13dce672f5f1900bd448.png\"\/><figcaption><\/figcaption><\/figure>\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\/577646\/\"> https:\/\/habr.com\/ru\/articles\/577646\/<\/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>\u041a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u0441\u0430\u043c\u044b\u0435 &#171;\u0433\u043e\u0440\u044f\u0447\u0438\u0435&#187; \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0432\u0430\u0448\u0435\u043c PostgreSQL-\u0441\u0435\u0440\u0432\u0435\u0440\u0435? \u041f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u0438\u0445 \u0432 \u043b\u043e\u0433\u0435 \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u043d \u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/pgstatstatements\">pg_stat_statements<\/a>.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0432 \u043b\u043e\u0433 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0437\u0430 \u0441\u0443\u0442\u043a\u0438?.. \u0422\u043e\u0433\u0434\u0430 \u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043b\u0438\u043c\u0438\u0442\u0430 <code>pg_stat_statements.max<\/code> \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0435\u043b\u0438\u043a\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0434\u0438\u0432\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443. \u0422\u0430\u043a \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u0440\u044f\u043c\u043e \u0441 \u043f\u043b\u0430\u043d\u043e\u0432!<\/p>\n<p>\u041d\u043e \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 <a href=\"https:\/\/sbis.ru\/all_services\">\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0421\u0411\u0418\u0421<\/a> \u043d\u0430\u043c \u0432 <a href=\"https:\/\/tensor.ru\/\">&#171;\u0422\u0435\u043d\u0437\u043e\u0440\u0435&#187;<\/a> \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u0430, \u0447\u0442\u043e <code>auto_explain.log_min_duration<\/code> \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 <strong>\u0435\u0434\u0438\u043d\u0438\u0446\u044b \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434<\/strong> &#8212; \u0438 \u0432\u043e\u0442 \u043e\u043d\u0438, \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u043f\u043b\u0430\u043d\u043e\u0432&#8230; \u041a\u0430\u043a \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u0438\u0445?<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u041e\u0442 \u043f\u043b\u0430\u043d\u043e\u0432 &#8212; \u043a \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tst AS SELECT   * , CASE     WHEN r &lt; 0.9    THEN 0     WHEN r &lt; 0.99   THEN 1     WHEN r &lt; 0.999  THEN 2     WHEN r &lt; 0.9999 THEN 3   END v FROM   (     SELECT       i     , random() r     FROM       generate_series(1, 1e4) i   ) T;  CREATE INDEX ON tst(v); ANALYZE tst;<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u043b\u0430\u043d \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0438 <code>v = 0<\/code>:<\/p>\n<pre><code class=\"sql\">EXPLAIN (ANALYZE, BUFFERS, COSTS OFF) SELECT   * FROM   tst WHERE   v = 0;<\/code><\/pre>\n<pre><code>Seq Scan on tst (actual time=0.023..1.236 rows=9034 loops=1)   Filter: (v = 0)   Rows Removed by Filter: 966   Buffers: shared hit=64<\/code><\/pre>\n<p>&#8230; <code>v = 1<\/code>:<\/p>\n<pre><code>Bitmap Heap Scan on tst (actual time=0.074..0.286 rows=876 loops=1)   Recheck Cond: (v = 1)   Heap Blocks: exact=64   Buffers: shared hit=69   ->  Bitmap Index Scan on tst_v_idx (actual time=0.058..0.058 rows=876 loops=1)         Index Cond: (v = 1)         Buffers: shared hit=5<\/code><\/pre>\n<p>&#8230; <code>v = 2<\/code>:<\/p>\n<pre><code>Bitmap Heap Scan on tst (actual time=0.047..0.106 rows=83 loops=1)   Recheck Cond: (v = 2)   Heap Blocks: exact=45   Buffers: shared hit=47   ->  Bitmap Index Scan on tst_v_idx (actual time=0.031..0.031 rows=83 loops=1)         Index Cond: (v = 2)         Buffers: shared hit=2<\/code><\/pre>\n<p>\u0438 <code>v = 3<\/code>, \u043d\u0430\u043a\u043e\u043d\u0435\u0446:<\/p>\n<pre><code>Index Scan using tst_v_idx on tst (actual time=0.020..0.026 rows=6 loops=1)   Index Cond: (v = 3)   Buffers: shared hit=8<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u043b\u0430\u043d\u043e\u0432 \u043e\u0442 &#171;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439&#187; \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u0440\u043e\u0434\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <strong>&#171;\u0448\u0430\u0431\u043b\u043e\u043d&#187; \u043f\u043b\u0430\u043d\u0430<\/strong> &#8212; \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code>-- v = 0 Seq Scan on tst<\/code><\/pre>\n<pre><code>-- v = 1, v = 2 Bitmap Heap Scan on tst   ->  Bitmap Index Scan on tst_v_idx<\/code><\/pre>\n<pre><code>-- v = 3 Index Scan using tst_v_idx on tst<\/code><\/pre>\n<p>\u0420\u043e\u0432\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438 <a href=\"https:\/\/explain.tensor.ru\/\">\u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043b\u0430\u043d\u043e\u0432<\/a>, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432\u0430\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0430\u044f \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u043f\u043b\u0430\u043d\u043e\u0432 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0432 \u0441\u043e\u0442\u043d\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432.<\/p>\n<h2>\u041e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 &#8212; \u043a \u043c\u043e\u0434\u0435\u043b\u044f\u043c<\/h2>\n<p>\u041d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b <strong>\u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441<\/strong> &#171;\u043d\u0430 \u0432\u0445\u043e\u0434\u0435&#187;, \u0430 &#171;\u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435&#187; \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0430\u0436 <strong>3 \u0440\u0430\u0437\u043d\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u0430<\/strong>! \u0418 \u0435\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0432\u043e\u0434\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e &#171;\u0442\u043e\u043f\u043e\u0432\u044b\u043c&#187; \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0443\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u0432\u0435\u0434\u044c \u0435\u0433\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 &#171;\u0440\u0430\u0437\u043c\u0430\u0437\u0430\u043d\u044b&#187; \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u044f\u043c.<\/p>\n<p>\u041d\u043e \u0432\u0435\u0434\u044c, \u0432\u043e \u0432\u0441\u0435\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>tst<\/code>, \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438: <code>Seq Scan<\/code>, <code>Bitmap Scan<\/code> \u0438 <code>Index Scan<\/code> &#8212; \u0438 \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d &#171;\u0440\u0430\u0437\u0431\u0435\u0433\u0430\u043d\u0438\u044f&#187; \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0430 \u0438\u0445 \u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u00a0\u0432\u0438\u0434 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u00a0(<code>Nested Loop<\/code>, <code>Hash Semi Join<\/code>, <code>Merge Join<\/code>, &#8230;)<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u043b\u0438\u0447\u0438\u0435\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435\/\u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0430\u043b\u0438\u0430\u0441\u043e\u0432\u00a0\u0443 \u043e\u0434\u043d\u0438\u0445 \u0438 \u0442\u0435\u0445 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0447\u0442\u0435\u043d\u0438\u0439\u00a0(<code>Index Only Scan<\/code> \/ <code>Index Scan<\/code> \/ <code>Bitmap Index Scan<\/code>) \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u00a0\u043f\u0440\u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (<code>Seq Scan<\/code> vs <code>Parallel Seq Scan<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u043b\u0438\u0447\u0438\u0435\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439\u00a0\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \/ \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \/ \u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u00a0\u0434\u043b\u044f <code>WindowAgg<\/code><\/p>\n<\/li>\n<li>\n<p>\u0441\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u00a0\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u0432, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e <strong>\u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043b\u0430\u043d\u0430<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0438 \u0431\u044b (\u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e) \u0432\u0441\u0435 \u043f\u043b\u0430\u043d\u044b \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u043b\u0430\u043d\u0430\u00a0(<code>CTE \/ InitPlan \/ SubPlan \/ Append<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0432 <code>Scan Table<\/code><\/p>\n<\/li>\n<li>\n<p>\u0432\u043c\u0435\u0441\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 <code>Join\/Loop<\/code>-\u0443\u0437\u043b\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0434\u0438\u043d <code>Join<\/code> \u0441\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0437\u043b\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0440\u043e\u0434\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u043e\u0431\u0449\u0438\u0439 \u0443\u0437\u0435\u043b <code>Process<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u0434 \u043d\u0430\u0448\u0438\u043c\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u0435\u0434\u0438\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code>Scan Table tst<\/code><\/pre>\n<p>\u0415\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/940af12543268372e8dc426cc516080d:0:2021-09-13#domain\">\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0432\u043a\u043b\u0430\u0434\u043a\u0435<\/a> \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043b\u0430\u043d\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d \u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>&#8230; \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>Process   InitPlan 1     ->  Process           ->  Scan Table \"request-statuses\"   InitPlan 2     ->  Process           ->  Scan Table \"request-statuses\"   ->  Join         ->  Scan Table \"request-statuses\"         ->  Scan Table \"task-tracker-times\"         ->  Scan Table requests         ->  Scan Table tasks<\/code><\/pre>\n<p>\u0421\u043e\u0442\u043d\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0443\u0436\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<h2>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u043b\u0430\u043d\u043e\u0432<\/h2>\n<p>\u041d\u043e \u0441\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0434\u043b\u044f &#171;\u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445&#187; \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0427\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code>->  Scan Table tst         | A       ->  InitPlan 1       | B             -> Scan Values | B<\/code><\/pre>\n<pre><code>->  Scan Table tst         | A       SubPlan 1            | C         ->  Scan Table tst | C<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0443 &#171;\u043f\u043e\u0445\u043e\u0436\u0435\u0441\u0442\u0438&#187; \u0434\u0432\u0443\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439? \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0437\u0443\u0431\u043e\u0434\u0440\u043e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443, \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438, \u0441\u0443\u043f\u0435\u0440\u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b&#8230;<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0443 \u043e\u0431\u0435\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e \u043e\u0431\u0449\u0438\u0439 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <code>A<\/code> . \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 <code>B<\/code> \u0438 <code>C<\/code> \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u0430\u043c\u0438 \u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u043a \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0443\u0437\u043b\u0430 \u0432 \u0442\u0430\u043a\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438 \u043f\u043e\u0438\u0441\u043a \u043d\u0443\u0436\u043d\u043e\u0439 \u0438\u0433\u043e\u043b\u043a\u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u0433\u0435 \u0441\u0435\u043d\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\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\/577646\/\"> https:\/\/habr.com\/ru\/articles\/577646\/<\/a><br \/><\/br><\/br><\/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-405907","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/405907","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=405907"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/405907\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=405907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=405907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=405907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}