{"id":443196,"date":"2024-12-26T06:04:36","date_gmt":"2024-12-26T06:04:36","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=443196"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=443196","title":{"rendered":"<span>POSTGRES EXPLAIN<\/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>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041d\u0430 \u0441\u0432\u044f\u0437\u0438 \u0420\u0438\u0448\u0430\u0442 \u0421\u0430\u0434\u044b\u043a\u043e\u0432 \u0438\u0437 <a href=\"https:\/\/digital-spectr.ru\/?utm_source=habr\"><u>Spectr<\/u><\/a>. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e explain \u0432 Postgres. \u042d\u0442\u043e \u043e\u0431\u044a\u0435\u043c\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u043f\u043e \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f explain. \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0442\u0435\u043c, \u043a\u0442\u043e \u044d\u0442\u0438\u043c \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f.<\/p>\n<h2>\u041e\u0431\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u043e explain<\/h2>\n<p>SQL \u2014 \u044d\u0442\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c. \u041d\u043e \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u2014 \u0440\u0435\u0448\u0430\u0435\u0442 \u0421\u0423\u0411\u0414.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0d5\/29c\/126\/0d529c126c4728f8fc705e8a7169f634.png\" width=\"1600\" height=\"900\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0d5\/29c\/126\/0d529c126c4728f8fc705e8a7169f634.png\"\/><\/figure>\n<p>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>\u041f\u043b\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u2014 \u044d\u0442\u043e \u0434\u0435\u0440\u0435\u0432\u043e, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0445 \u0437\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (\u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430). \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0438\u043c\u0435\u0435\u0442 \u043e\u0446\u0435\u043d\u043a\u0443 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. EXPLAIN \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u043f\u043b\u0430\u043d\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0449\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043b\u0430\u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<pre><code class=\"pgsql\">Gather Merge  (cost=262477.81..358808.03 rows=825630 width=400) Workers Planned: 2 -&gt;  Sort  (cost=261477.78..262509.82 rows=412815 width=400)       Sort Key: a.column_x       -&gt;  Parallel Hash Join  (cost=6587.33..73403.18 rows=412815 width=400)             Hash Cond: (a.foreign_key = b.id)             -&gt;  Parallel Seq Scan on table_a a (cost=0.00..25147.19 rows=412815 width=368)                   Filter: (filter_condition = 'value')             -&gt;  Parallel Hash  (cost=3542.37..3542.37 rows=157437 width=32)                   -&gt;  Parallel Seq Scan on table_b b  (cost=0.00..3542.37 rows=157437 width=32) JIT: Functions: 12 Options: Inlining false, Optimization false, Expressions true, Deforming true  <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5bf\/84e\/e96\/5bf84ee964cf207117aa29de17ff5148.png\" width=\"925\" height=\"329\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5bf\/84e\/e96\/5bf84ee964cf207117aa29de17ff5148.png\"\/><\/figure>\n<p>\u041e\u0446\u0435\u043d\u043a\u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>seq_page_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u0434\u0438\u0441\u043a\u0430. \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u2014 \u044d\u0442\u043e \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 8\u041a\u0431, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<\/li>\n<li>\n<p>random_page_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u0434\u0438\u0441\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>cpu_tuple_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>cpu_index_tuple_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u0440\u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>cpu_operator_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>effective_cache_size \u2014 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043a\u0435\u0448\u0430, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0445 postgres. \u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 pg_stats \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 pg_statistic.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ec\/973\/b88\/8ec973b88969da251cc879514fc1c356.png\" width=\"644\" height=\"181\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ec\/973\/b88\/8ec973b88969da251cc879514fc1c356.png\"\/><\/figure>\n<p>avg_width \u2014 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0445\u0441\u044f \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 attname \u0442\u0430\u0431\u043b\u0438\u0446\u044b tablename.<br \/>\u0412 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 pg_class \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043e\u0431\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445. <\/p>\n<p>\u0412 \u043f\u043e\u043b\u0435 reltuples \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 relname.<br \/>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 explain.\u00a0<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f total_cost seqscan \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430: <br \/>total_cost = relpages*seq_page_cost + reltuples*cpu_tuple_cost + reltuples*cpu_operator_cost<br \/>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f rows \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437 reltuples, \u0434\u043b\u044f width \u043a\u0430\u043a \u0441\u0443\u043c\u043c\u0430 avg_width \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0443\u0437\u043b\u0435.<\/p>\n<h2>Analyse<\/h2>\n<p>\u041a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438? \u0414\u0430\u043d\u043d\u044b\u0435 reltuples \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 VACUUM, ANALYZE \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 DDL, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 CREATE INDEX. \u0414\u0430\u043d\u043d\u044b\u0435 avg_width \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 ANALYZE \u0438 VACUUM ANALYZE.<\/p>\n<h2>\u0412\u0438\u0434\u044b \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<h3>Sequential scan<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/876\/c34\/f49\/876c34f4937fbaa98c7c011915e98a17.png\" width=\"623\" height=\"317\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/876\/c34\/f49\/876c34f4937fbaa98c7c011915e98a17.png\"\/><\/figure>\n<p>\u041f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043c\u0438\u043d\u0443\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c \u043e\u0442\u0431\u043e\u0440\u0430. \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 WHERE, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u043f\u0440\u0438 \u043d\u0438\u0437\u043a\u043e\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a \u0438\u043b\u0438 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u0440\u043e\u043a \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435.<\/p>\n<h3>Index scan<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/090\/9b0\/c32\/0909b0c3220f64bcca00dfd5926aac53.png\" width=\"368\" height=\"379\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/090\/9b0\/c32\/0909b0c3220f64bcca00dfd5926aac53.png\"\/><\/figure>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 (index scan) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. <\/p>\n<h3>Index only scan<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dc0\/d59\/e5d\/dc0d59e5d236b693a945adca9c514a20.png\" width=\"787\" height=\"380\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dc0\/d59\/e5d\/dc0d59e5d236b693a945adca9c514a20.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (index only scan) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043d\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0442\u0440\u043e\u043a \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0440\u0442\u0430 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (visibility map). \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0439 \u0432 \u043a\u0430\u0440\u0442\u0435, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0434\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043a\u0430\u0440\u0442\u0430 \u043d\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e, \u0447\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<h3>Bitmap scan<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cd8\/610\/8de\/cd86108de10afcfdb5a49054844141a2.png\" width=\"850\" height=\"327\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cd8\/610\/8de\/cd86108de10afcfdb5a49054844141a2.png\"\/><\/figure>\n<p>Bitmap scan \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u0438\u0442\u043e\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. \u041f\u043e\u0441\u043b\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442 \u043a \u043d\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 BitmapAnd\/BitmapOr, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0417\u0430\u0442\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f, \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437.<\/p>\n<h2>\u0412\u0438\u0434\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0441\u0442\u0440\u043e\u043a<\/h2>\n<ol>\n<li>\n<p><strong>nested loop<\/strong><br \/>\u041c\u0435\u0442\u043e\u0434 \u00ab\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b\u00bb \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438 \u0438\u0449\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u043b\u044f \u0438\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u044d\u043a\u0432\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>hash join<\/strong><br \/>\u041f\u0440\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439 \u0432 \u043d\u0435\u0439. \u041a\u043b\u044e\u0447\u043e\u043c \u0441\u043b\u0443\u0436\u0438\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u044d\u043a\u0432\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>merge join<\/strong><br \/>\u041c\u0435\u0442\u043e\u0434 \u0441\u043b\u0438\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0421\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u043e\u0431\u043e\u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043f\u043e\u043b\u044f\u043c. \u041f\u0440\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u044d\u043a\u0432\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ol>\n<h2>\u041e\u043f\u0446\u0438\u044f ANALYSE<\/h2>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 EXPLAIN \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 ANALYSE, \u0447\u0442\u043e\u0431\u044b \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0438 \u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. <br \/>\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442! \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 explain \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0438 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0411\u0414 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c.<\/p>\n<pre><code class=\"pgsql\">EXPLAIN ANALYZE SELECT * FROM table_a a JOIN table_b b ON a.column_x = b.column_x; Gather  (cost=1014.73..33104.71 rows=49744 width=719) (actual time=16.917..19.460 rows=0 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Hash Join  (cost=14.72..27130.31 rows=20727 width=719) (actual time=0.913..0.915 rows=0 loops=3)       Hash Cond: (a.column_x = b.column_x)       -&gt;  Parallel Seq Scan on table_a a  (cost=0.00..18727.50 rows=284550 width=368) (actual time=0.826..0.827 rows=1 loops=3)       -&gt;  Hash  (cost=12.10..12.10 rows=210 width=351) (actual time=0.003..0.003 rows=0 loops=3)             Buckets: 1024  Batches: 1  Memory Usage: 8kB             -&gt;  Seq Scan on table_b b  (cost=0.00..12.10 rows=210 width=351) (actual time=0.003..0.003 rows=0 loops=3) Planning Time: 0.220 ms Execution Time: 19.502 ms<\/code><\/pre>\n<p>\u0412\u044b\u0448\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b EXPLAIN \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 ANALYSE. \u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0442. \u0434.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h3>\n<p><strong>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 <\/strong><\/p>\n<pre><code class=\"pgsql\">EXPLAIN (ANALYZE) SELECT * FROM table_a ORDER BY column_x;  Gather Merge  (cost=2801262.71..3781518.52 rows=8401606 width=368) (actual time=9601.004..11048.372 rows=10081680 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Sort  (cost=2800262.69..2810764.70 rows=4200803 width=368) (actual time=9519.614..9716.411 rows=3360560 loops=3)       Sort Key: table_a.column_x       Sort Method: external merge  Disk: 337056kB       Worker 0:  Sort Method: external merge  Disk: 367584kB       Worker 1:  Sort Method: external merge  Disk: 396920kB       -&gt;  Parallel Append  (cost=0.00..227469.94 rows=4200803 width=368) (actual time=4.121..8693.221 rows=3360560 loops=3)             -&gt;  Seq Scan on table_a_1 table_a_1  (cost=0.00..0.00 rows=1 width=368) (actual time=0.009..0.009 rows=0 loops=1)   ... Planning Time: 2482.305 ms Execution Time: 11238.612 ms<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f 11,2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041c\u044b \u0432\u0438\u0434\u0438\u043c \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0438\u0441\u043a\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438 <strong>Sort<\/strong> <strong>Method<\/strong>: <strong>external<\/strong> <strong>merge<\/strong>: 337056kB. \u041e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043b\u0438\u043c\u0438\u0442, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0441\u043a. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0438\u0441\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u0417\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u0438\u043c\u0438\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 work_mem. \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u0435\u0433\u043e \u0434\u043e 800Mb \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c explain \u0435\u0449\u0435 \u0440\u0430\u0437.<\/p>\n<pre><code class=\"pgsql\">SET work_mem = '800MB'; EXPLAIN (ANALYZE) SELECT * FROM table_a ORDER BY column_x; Gather Merge  (cost=1394157.71..2374413.52 rows=8401606 width=368) (actual time=684.390..2073.879 rows=10081680 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Sort  (cost=1393157.69..1403659.70 rows=4200803 width=368) (actual time=639.491..819.908 rows=3360560 loops=3)       Sort Key: table_a.column_x       Sort Method: quicksort  Memory: 639232kB       Worker 0:  Sort Method: quicksort  Memory: 695053kB       Worker 1:  Sort Method: quicksort  Memory: 699096kB       -&gt;  Parallel Append  (cost=0.00..227469.94 rows=4200803 width=368) (actual time=0.037..279.005 rows=3360560 loops=3)             -&gt;  Seq Scan on table_a_1 table_a_1  (cost=0.00..0.00 rows=1 width=368) (actual time=0.008..0.008 rows=0 loops=1)   ... Planning Time: 5.054 ms Execution Time: 2252.396 ms<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0430\u0441\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u0438\u0441\u043a\u0430. \u041e\u0431 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u2014 <strong>Sort Method: quicksort\u00a0 Memory<\/strong>: 639232kB <br \/>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f work_mem \u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 work_mem. \u0412 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0447\u043d\u0443\u0442 \u0432\u044b\u0442\u0435\u0441\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0435\u0430\u043d\u0441\u0430\u0445. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u0431\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 work_mem. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 800Mb \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c \u0441 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.\u00a0<\/p>\n<p><strong>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441:<\/strong><\/p>\n<pre><code class=\"pgsql\">EXPLAIN (ANALYZE) SELECT * FROM schema_a.table_b WHERE user_id = 1 ORDER BY column_y;  Gather Merge  (cost=36081.79..63169.48 rows=232164 width=368) (actual time=31.333..72.066 rows=278594 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Sort  (cost=35081.77..35371.97 rows=116082 width=368) (actual time=19.472..24.289 rows=92865 loops=3)       Sort Key: table_b.column_y       Sort Method: external merge  Disk: 14232kB       Worker 0:  Sort Method: external merge  Disk: 4896kB       Worker 1:  Sort Method: external merge  Disk: 6160kB       -&gt;  Parallel Append  (cost=0.00..5873.99 rows=116082 width=368) (actual time=0.009..8.534 rows=92865 loops=3)             -&gt;  Parallel Seq Scan on table_b_1 table_b_1  (cost=0.00..5163.05 rows=113444 width=368) (actual time=0.006..5.528 rows=90755 loops=3)                   Filter: (user_id = 1)             -&gt;  ... Planning Time: 1.946 ms Execution Time: 77.598 ms<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u044b \u043c\u0435\u043d\u044c\u0448\u0435 \u0438 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 work_mem \u0434\u043e 30 Mb.<\/p>\n<pre><code class=\"pgsql\">set work_mem='30MB'; Gather Merge  (cost=36081.79..63169.48 rows=232164 width=368) (actual time=29.750..63.125 rows=278594 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Sort  (cost=35081.77..35371.97 rows=116082 width=368) (actual time=17.767..20.840 rows=92865 loops=3)       Sort Key: table_b.column_y       Sort Method: quicksort  Memory: 26359kB       Worker 0:  Sort Method: quicksort  Memory: 12892kB       Worker 1:  Sort Method: quicksort  Memory: 13296kB       -&gt;  Parallel Append  (cost=0.00..5873.99 rows=116082 width=368) (actual time=0.007..8.641 rows=92865 loops=3)             -&gt;  Parallel Seq Scan on table_b_1 table_b_1  (cost=0.00..5163.05 rows=113444 width=368) (actual time=0.005..5.642 rows=90755 loops=3)                   Filter: (user_id = 45)             -&gt;  ... Planning Time: 2.012 ms Execution Time: 69.087 ms<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 work_mem \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0421\u0423\u0411\u0414 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c.\u00a0<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c join:<\/strong><\/p>\n<pre><code class=\"pgsql\">EXPLAIN ANALYZE SELECT * FROM schema_a.table_a f JOIN schema_b.table_b b ON b.id = f.bpo_id WHERE column_x &gt; 100;  Hash Join  (cost=10158.57..395715.04 rows=1275846 width=383) (actual time=17951.355..18798.673 rows=41 loops=1) Hash Cond: (f.bpo_id = b.id) -&gt;  Append  (cost=0.00..263263.32 rows=1275846 width=351) (actual time=17724.494..18673.100 rows=41 loops=1)       -&gt;  Seq Scan on table_a_1 f_1  (cost=0.00..12.62 rows=70 width=351) (actual time=0.038..0.038 rows=0 loops=1)             Filter: (column_x &gt; 100)       -&gt;  ... -&gt;  Hash  (cost=5000.92..5000.92 rows=266692 width=32) (actual time=79.247..79.249 rows=267643 loops=1)       Buckets: 65536  Batches: 8  Memory Usage: 2618kB       -&gt;  Seq Scan on table_b b  (cost=0.00..5000.92 rows=266692 width=32) (actual time=0.017..18.741 rows=267643 loops=1) Planning Time: 1617.770 ms JIT: Functions: 2931 Options: Inlining false, Optimization false, Expressions true, Deforming true Timing: Generation 1943.363 ms, Inlining 0.000 ms, Optimization 1580.248 ms, Emission 15330.172 ms, Total 18853.783 ms Execution Time: 20788.785 ms<\/code><\/pre>\n<p>\u041f\u043e \u043f\u043b\u0430\u043d\u0443 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f hash join.\u00a0<\/p>\n<p>\u0421\u0442\u0440\u043e\u043a\u0430 \u2018Buckets: 65536\u00a0 Batches: 8\u00a0 Memory <strong>Usage<\/strong>: 2618kB\u2019<\/p>\n<p>\u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u0431\u044b\u043b\u043e 65536 \u043a\u043e\u0440\u0437\u0438\u043d (Buckets), \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u0438\u0445 \u043a\u043e\u0440\u0437\u0438\u043d \u0431\u043e\u043b\u044c\u0448\u0435: \u0432\u0441\u0435 \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438\u0441\u044c \u0432 work_mem, \u0442\u0430\u043a \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0435\u0438\u0306\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043e 8 (Batches) \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. <br \/>\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u043c work_mem c 4 \u0434\u043e 30\u041c\u0431 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u2014 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 EXPLAIN \u0435\u0449\u0435 \u0440\u0430\u0437:<\/p>\n<pre><code class=\"pgsql\">SET work_mem = '30MB';  EXPLAIN ANALYZE SELECT * FROM schema_a.table_a f JOIN schema_b.table_b b ON b.id = f.bpo_id WHERE column_x &gt; 100;  Hash Join  (cost=8334.57..274947.04 rows=1275846 width=383) (actual time=17890.816..18842.765 rows=41 loops=1) Hash Cond: (f.bpo_id = b.id) -&gt;  Append  (cost=0.00..263263.32 rows=1275846 width=351) (actual time=17800.680..18752.489 rows=41 loops=1)       -&gt;  Seq Scan on table_a_1 f_1  (cost=0.00..12.62 rows=70 width=351) (actual time=0.040..0.041 rows=0 loops=1)             Filter: (column_x &gt; 100)       -&gt;  ... -&gt;  Hash  (cost=5000.92..5000.92 rows=266692 width=32) (actual time=87.282..87.283 rows=267643 loops=1)       Buckets: 524288  Batches: 1  Memory Usage: 20824kB       -&gt;  Seq Scan on table_b b  (cost=0.00..5000.92 rows=266692 width=32) (actual time=0.023..18.929 rows=267643 loops=1) Planning Time: 213.257 ms JIT: Functions: 2931 Options: Inlining false, Optimization false, Expressions true, Deforming true Timing: Generation 1793.908 ms, Inlining 0.000 ms, Optimization 1586.443 ms, Emission 15452.539 ms, Total 18832.890 ms Execution Time: 20682.344 ms<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u044f \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 524288 \u043a\u043e\u0440\u0437\u0438\u043d \u0443\u043c\u0435\u0441\u0442\u0438\u043b\u0430\u0441\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 (Batches: 1), \u043d\u043e \u043d\u0430 \u043e\u0431\u0449\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u044d\u0442\u043e \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0442\u0430\u043a\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u043d\u0430\u0434 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 work_mem \u043c\u043e\u0436\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430: <\/strong><\/p>\n<pre><code class=\"pgsql\">EXPLAIN ANALYZE SELECT * FROM schema_a.table_a WHERE column_x &gt; 100; Gather  (cost=1000.00..1867776.17 rows=109335 width=675) (actual time=8523.234..17485.661 rows=7965 loops=1) Workers Planned: 4 Workers Launched: 4 -&gt;  Parallel Append  (cost=0.00..1855842.67 rows=27345 width=675) (actual time=1703.379..10913.290 rows=1593 loops=5)       -&gt;  Parallel Seq Scan on table_a_month_2024_09 table_a_35  (cost=0.00..146392.54 rows=2587 width=675) (actual time=0.386..791.368 rows=707 loops=1)             Filter: (column_x &gt; 100)             Rows Removed by Filter: 2992662       -&gt;  ... Planning Time: 61.016 ms Execution Time: 17488.673 ms<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432\u0441\u0435 \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0415\u0441\u043b\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e \u0438 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0443 column_x. \u041d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0430\u043b\u043a\u0430 \u043e \u0434\u0432\u0443\u0445 \u043a\u043e\u043d\u0446\u0430\u0445. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0438 \u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430), \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \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 \u043d\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0412 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0447\u0430\u0441\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441. \u041e\u043d \u0443\u0441\u043a\u043e\u0440\u0438\u0442 \u0447\u0430\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0441\u0430\u0434\u043a\u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c, \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u043c\u044f\u0442\u044c, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c, \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u044c, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u0430\u044f \u043f\u043e\u043b\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c.<\/p>\n<pre><code class=\"pgsql\">EXPLAIN ANALYZE SELECT * FROM schema_a.table_a f WHERE f.date BETWEEN '2024-01-01' AND '2024-06-01'; Gather  (cost=1000.00..678031.78 rows=547514 width=675) (actual time=573.888..641.552 rows=552951 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Parallel Seq Scan on table_a f  (cost=0.00..622280.38 rows=228131 width=675) (actual time=557.001..596.104 rows=184317 loops=3)       Filter: ((date &gt;= '2024-01-01'::date) AND (date &lt;= '2024-06-01'::date))       Rows Removed by Filter: 4672236 Planning Time: 0.260 ms JIT: Functions: 6 Options: Inlining true, Optimization true, Expressions true, Deforming true Timing: Generation 0.599 ms, Inlining 117.227 ms, Optimization 14.718 ms, Emission 15.567 ms, Total 148.111 ms Execution Time: 658.582 ms<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"pgsql\">EXPLAIN ANALYZE SELECT * FROM schema_a.table_a f WHERE f.date BETWEEN '2024-01-01' AND '2024-06-01'; Gather  (cost=1000.00..678031.78 rows=547514 width=675) (actual time=573.888..641.552 rows=552951 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Parallel Seq Scan on table_a f  (cost=0.00..622280.38 rows=228131 width=675) (actual time=557.001..596.104 rows=184317 loops=3)       Filter: ((date &gt;= '2024-01-01'::date) AND (date &lt;= '2024-06-01'::date))       Rows Removed by Filter: 4672236 Planning Time: 0.260 ms JIT: Functions: 6 Options: Inlining true, Optimization true, Expressions true, Deforming true Timing: Generation 0.599 ms, Inlining 117.227 ms, Optimization 14.718 ms, Emission 15.567 ms, Total 148.111 ms Execution Time: 658.582 ms<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0435\u0435 \u043f\u043e \u043f\u043e\u043b\u044e date, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441, \u043d\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0440\u0435\u0448\u0438\u043b \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u043b \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>\u041e\u0442\u043a\u043b\u044e\u0447\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u043d\u043e\u0432\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c explain:<\/p>\n<pre><code class=\"pgsql\">SET enable_seqscan = OFF;  EXPLAIN ANALYZE SELECT * FROM schema_a.table_a f WHERE f.date BETWEEN '2024-01-01' AND '2024-06-01';  Gather  (cost=8472.45..697646.91 rows=547514 width=675) (actual time=31.362..128.172 rows=552951 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Parallel Bitmap Heap Scan on table_a f  (cost=7472.45..641895.51 rows=228131 width=675) (actual time=16.629..87.796 rows=184317 loops=3)       Recheck Cond: ((date &gt;= '2024-01-01'::date) AND (date &lt;= '2024-06-01'::date))       Heap Blocks: exact=8846       -&gt;  Bitmap Index Scan on table_a_date_index  (cost=0.00..7335.58 rows=547514 width=0) (actual time=27.439..27.440 rows=552951 loops=1)             Index Cond: ((date &gt;= '2024-01-01'::date) AND (date &lt;= '2024-06-01'::date)) Planning Time: 0.265 ms JIT: Functions: 6 Options: Inlining true, Optimization true, Expressions true, Deforming true Timing: Generation 0.626 ms, Inlining 0.000 ms, Optimization 0.000 ms, Emission 0.000 ms, Total 0.626 ms Execution Time: 145.257 ms<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 4 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435. \u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0432\u044b\u0431\u0440\u0430\u043b \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u0430\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0435. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b seq_page_cost \u0438 random_page_cost \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0432\u043d\u044b\u0435 1 \u0438 4. \u0422\u0430\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u044b \u0434\u043b\u044f \u0436\u0435\u0441\u0442\u043a\u0438\u0445 \u0434\u0438\u0441\u043a\u043e\u0432, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0438\u0436\u0443\u0449\u0430\u044f\u0441\u044f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0433\u043e\u043b\u043e\u0432\u043a\u0430, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441 \u0434\u0438\u0441\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0412 \u0442\u0432\u0435\u0440\u0434\u043e\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044f\u0445 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043d\u0435\u0442 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 random_page_cost \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435. \u0412\u043a\u043b\u044e\u0447\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 random_page_cost \u0440\u0430\u0432\u043d\u043e\u0435 1.1 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043d\u043e\u0432\u0430.<\/p>\n<pre><code class=\"pgsql\">SET enable_seqscan = ON;  SET random_page_cost = 1.1;  EXPLAIN ANALYZE SELECT * FROM schema_a.table_a f WHERE f.date BETWEEN '2024-01-01' AND '2024-06-01';  Gather  (cost=8472.45..697646.91 rows=547514 width=675) (actual time=31.362..128.172 rows=552951 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Parallel Bitmap Heap Scan on table_a f  (cost=7472.45..641895.51 rows=228131 width=675) (actual time=16.629..87.796 rows=184317 loops=3)       Recheck Cond: ((date &gt;= '2024-01-01'::date) AND (date &lt;= '2024-06-01'::date))       Heap Blocks: exact=8846       -&gt;  Bitmap Index Scan on table_a_date_index  (cost=0.00..7335.58 rows=547514 width=0) (actual time=27.439..27.440 rows=552951 loops=1)             Index Cond: ((date &gt;= '2024-01-01'::date) AND (date &lt;= '2024-06-01'::date)) Planning Time: 0.265 ms JIT: Functions: 6 Options: Inlining true, Optimization true, Expressions true, Deforming true Timing: Generation 0.626 ms, Inlining 0.000 ms, Optimization 0.000 ms, Emission 0.000 ms, Total 0.626 ms Execution Time: 145.257 ms<\/code><\/pre>\n<p>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u043b \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.\u00a0<\/p>\n<h2>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u043f\u043b\u0430\u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u043b\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u043c \u0438 \u0432 \u043d\u0435\u043c \u0442\u0440\u0443\u0434\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0435 \u0443\u0437\u043b\u044b. \u0414\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u043f\u043b\u0430\u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u0441\u0430\u043c\u044b\u0435 \u0442\u044f\u0436\u0435\u043b\u044b\u0435 \u0443\u0437\u043b\u044b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d70\/916\/90f\/d7091690f0d31145f5761c4c0486a0ea.png\" width=\"843\" height=\"600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d70\/916\/90f\/d7091690f0d31145f5761c4c0486a0ea.png\"\/><\/figure>\n<p>\u0415\u0441\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u044e\u0442 \u0441\u043e\u0432\u0435\u0442\u044b \u043f\u043e \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/explain.tensor.ru\/plan\/\"><u>https:\/\/explain.tensor.ru\/plan\/<\/u><br \/><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/08b\/08a\/2fb\/08b08a2fb4cc880982e09b963c7a23bd.png\" width=\"1008\" height=\"299\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/08b\/08a\/2fb\/08b08a2fb4cc880982e09b963c7a23bd.png\"\/><\/figure>\n<h2>\u041f\u043e\u0438\u0441\u043a \u00ab\u0442\u044f\u0436\u0435\u043b\u044b\u0445\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h2>\n<p>\u0412 Postgres \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c pg_stat_statements. \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u043d\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c pg_stat_statements \u0432 shared_preload_libraries \u0432 \u0444\u0430\u0439\u043b\u0435 postgresql.conf. \u041f\u043e\u0441\u043b\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430\u0447\u043d\u0435\u0442\u0441\u044f \u0441\u0431\u043e\u0440 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 pg_stat_statements. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0442 \u0441\u0430\u043c\u044b\u0445 \u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u043a \u0441\u0430\u043c\u044b\u043c \u043b\u0435\u0433\u043a\u0438\u043c.<\/p>\n<pre><code class=\"pgsql\">SELECT query, calls,     round(total_exec_time::numeric, 2) AS total_time,     round(mean_exec_time::numeric, 2) AS mean_time,     round((100 * total_exec_time \/ sum(total_exec_time) OVER ())::numeric, 2) AS percentage FROM  pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;<\/code><\/pre>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>Query<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>Calls<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>Total Time<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>Mean Time<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>Percentage<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">SELECT query, calls. round(total_exec time::numeric. $1) AS total ti<\/p>\n<\/td>\n<td>\n<p align=\"left\">333<\/p>\n<\/td>\n<td>\n<p align=\"left\">37 533.86<\/p>\n<\/td>\n<td>\n<p align=\"left\">112.71<\/p>\n<\/td>\n<td>\n<p align=\"left\">23.95<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">SELECT &#171;general&#187;. &#171;table_a&#187;. &#171;id&#187;, &#171;general&#187;. &#171;table_b&#187;,<\/p>\n<\/td>\n<td>\n<p align=\"left\">2<\/p>\n<\/td>\n<td>\n<p align=\"left\">31 888.83<\/p>\n<\/td>\n<td>\n<p align=\"left\">15 944.41<\/p>\n<\/td>\n<td>\n<p align=\"left\">20.35<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b EXPLAIN \u0432 PostgreSQL \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435, \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0435 \u0438 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u043a \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041c\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e EXPLAIN \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a PostgreSQL \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u043f\u0446\u0438\u0438 ANALYZE. \u042d\u0442\u043e \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u0443\u0437\u043a\u0438\u0435 \u043c\u0435\u0441\u0442\u0430 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c EXPLAIN \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 PostgreSQL \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u043e \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0447\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/869472\/\"> https:\/\/habr.com\/ru\/articles\/869472\/<\/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>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041d\u0430 \u0441\u0432\u044f\u0437\u0438 \u0420\u0438\u0448\u0430\u0442 \u0421\u0430\u0434\u044b\u043a\u043e\u0432 \u0438\u0437 <a href=\"https:\/\/digital-spectr.ru\/?utm_source=habr\"><u>Spectr<\/u><\/a>. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e explain \u0432 Postgres. \u042d\u0442\u043e \u043e\u0431\u044a\u0435\u043c\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u043f\u043e \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f explain. \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0442\u0435\u043c, \u043a\u0442\u043e \u044d\u0442\u0438\u043c \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f.<\/p>\n<h2>\u041e\u0431\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u043e explain<\/h2>\n<p>SQL \u2014 \u044d\u0442\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c. \u041d\u043e \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u2014 \u0440\u0435\u0448\u0430\u0435\u0442 \u0421\u0423\u0411\u0414.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>\u041f\u043b\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u2014 \u044d\u0442\u043e \u0434\u0435\u0440\u0435\u0432\u043e, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0445 \u0437\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (\u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430). \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0438\u043c\u0435\u0435\u0442 \u043e\u0446\u0435\u043d\u043a\u0443 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. EXPLAIN \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u043f\u043b\u0430\u043d\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0449\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043b\u0430\u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<pre><code class=\"pgsql\">Gather Merge  (cost=262477.81..358808.03 rows=825630 width=400) Workers Planned: 2 -&gt;  Sort  (cost=261477.78..262509.82 rows=412815 width=400)       Sort Key: a.column_x       -&gt;  Parallel Hash Join  (cost=6587.33..73403.18 rows=412815 width=400)             Hash Cond: (a.foreign_key = b.id)             -&gt;  Parallel Seq Scan on table_a a (cost=0.00..25147.19 rows=412815 width=368)                   Filter: (filter_condition = 'value')             -&gt;  Parallel Hash  (cost=3542.37..3542.37 rows=157437 width=32)                   -&gt;  Parallel Seq Scan on table_b b  (cost=0.00..3542.37 rows=157437 width=32) JIT: Functions: 12 Options: Inlining false, Optimization false, Expressions true, Deforming true  <\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0446\u0435\u043d\u043a\u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>seq_page_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u0434\u0438\u0441\u043a\u0430. \u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u2014 \u044d\u0442\u043e \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 8\u041a\u0431, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<\/li>\n<li>\n<p>random_page_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u0434\u0438\u0441\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>cpu_tuple_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>cpu_index_tuple_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u0440\u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>cpu_operator_cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>effective_cache_size \u2014 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043a\u0435\u0448\u0430, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0445 postgres. \u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 pg_stats \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 pg_statistic.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>avg_width \u2014 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0445\u0441\u044f \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 attname \u0442\u0430\u0431\u043b\u0438\u0446\u044b tablename.<br \/>\u0412 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 pg_class \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043e\u0431\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445. <\/p>\n<p>\u0412 \u043f\u043e\u043b\u0435 reltuples \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 relname.<br \/>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 explain.\u00a0<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f total_cost seqscan \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430: <br \/>total_cost = relpages*seq_page_cost + reltuples*cpu_tuple_cost + reltuples*cpu_operator_cost<br \/>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f rows \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437 reltuples, \u0434\u043b\u044f width \u043a\u0430\u043a \u0441\u0443\u043c\u043c\u0430 avg_width \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0443\u0437\u043b\u0435.<\/p>\n<h2>Analyse<\/h2>\n<p>\u041a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438? \u0414\u0430\u043d\u043d\u044b\u0435 reltuples \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 VACUUM, ANALYZE \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 DDL, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 CREATE INDEX. \u0414\u0430\u043d\u043d\u044b\u0435 avg_width \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 ANALYZE \u0438 VACUUM ANALYZE.<\/p>\n<h2>\u0412\u0438\u0434\u044b \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<h3>Sequential scan<\/h3>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043c\u0438\u043d\u0443\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c \u043e\u0442\u0431\u043e\u0440\u0430. \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 WHERE, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u043f\u0440\u0438 \u043d\u0438\u0437\u043a\u043e\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a \u0438\u043b\u0438 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u0440\u043e\u043a \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435.<\/p>\n<h3>Index scan<\/h3>\n<figure class=\"\"><\/figure>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 (index scan) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. <\/p>\n<h3>Index only scan<\/h3>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (index only scan) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043d\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0442\u0440\u043e\u043a \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0440\u0442\u0430 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (visibility map). \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0439 \u0432 \u043a\u0430\u0440\u0442\u0435, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0434\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043a\u0430\u0440\u0442\u0430 \u043d\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e, \u0447\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<h3>Bitmap scan<\/h3>\n<figure class=\"full-width\"><\/figure>\n<p>Bitmap scan \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u0438\u0442\u043e\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. \u041f\u043e\u0441\u043b\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442 \u043a \u043d\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 BitmapAnd\/BitmapOr, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0417\u0430\u0442\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f, \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437.<\/p>\n<h2>\u0412\u0438\u0434\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0441\u0442\u0440\u043e\u043a<\/h2>\n<ol>\n<li>\n<p><strong>nested loop<\/strong><br \/>\u041c\u0435\u0442\u043e\u0434 \u00ab\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b\u00bb \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438 \u0438\u0449\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u043b\u044f \u0438\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u044d\u043a\u0432\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>hash join<\/strong><br \/>\u041f\u0440\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439 \u0432 \u043d\u0435\u0439. \u041a\u043b\u044e\u0447\u043e\u043c \u0441\u043b\u0443\u0436\u0438\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u044d\u043a\u0432\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>merge join<\/strong><br \/>\u041c\u0435\u0442\u043e\u0434 \u0441\u043b\u0438\u044f\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0421\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u043e\u0431\u043e\u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043f\u043e\u043b\u044f\u043c. \u041f\u0440\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u044d\u043a\u0432\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ol>\n<h2>\u041e\u043f\u0446\u0438\u044f ANALYSE<\/h2>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 EXPLAIN \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 ANALYSE, \u0447\u0442\u043e\u0431\u044b \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0438 \u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. <br \/>\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442! \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 explain \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0438 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0411\u0414 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c.<\/p>\n<pre><code class=\"pgsql\">EXPLAIN ANALYZE SELECT * FROM table_a a JOIN table_b b ON a.column_x = b.column_x; Gather  (cost=1014.73..33104.71 rows=49744 width=719) (actual time=16.917..19.460 rows=0 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Hash Join  (cost=14.72..27130.31 rows=20727 width=719) (actual time=0.913..0.915 rows=0 loops=3)       Hash Cond: (a.column_x = b.column_x)       -&gt;  Parallel Seq Scan on table_a a  (cost=0.00..18727.50 rows=284550 width=368) (actual time=0.826..0.827 rows=1 loops=3)       -&gt;  Hash  (cost=12.10..12.10 rows=210 width=351) (actual time=0.003..0.003 rows=0 loops=3)             Buckets: 1024  Batches: 1  Memory Usage: 8kB             -&gt;  Seq Scan on table_b b  (cost=0.00..12.10 rows=210 width=351) (actual time=0.003..0.003 rows=0 loops=3) Planning Time: 0.220 ms Execution Time: 19.502 ms<\/code><\/pre>\n<p>\u0412\u044b\u0448\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b EXPLAIN \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 ANALYSE. \u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0442. \u0434.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h3>\n<p><strong>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 <\/strong><\/p>\n<pre><code class=\"pgsql\">EXPLAIN (ANALYZE) SELECT * FROM table_a ORDER BY column_x;  Gather Merge  (cost=2801262.71..3781518.52 rows=8401606 width=368) (actual time=9601.004..11048.372 rows=10081680 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Sort  (cost=2800262.69..2810764.70 rows=4200803 width=368) (actual time=9519.614..9716.411 rows=3360560 loops=3)       Sort Key: table_a.column_x       Sort Method: external merge  Disk: 337056kB       Worker 0:  Sort Method: external merge  Disk: 367584kB       Worker 1:  Sort Method: external merge  Disk: 396920kB       -&gt;  Parallel Append  (cost=0.00..227469.94 rows=4200803 width=368) (actual time=4.121..8693.221 rows=3360560 loops=3)             -&gt;  Seq Scan on table_a_1 table_a_1  (cost=0.00..0.00 rows=1 width=368) (actual time=0.009..0.009 rows=0 loops=1)   ... Planning Time: 2482.305 ms Execution Time: 11238.612 ms<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f 11,2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041c\u044b \u0432\u0438\u0434\u0438\u043c \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0438\u0441\u043a\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438 <strong>Sort<\/strong> <strong>Method<\/strong>: <strong>external<\/strong> <strong>merge<\/strong>: 337056kB. \u041e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043b\u0438\u043c\u0438\u0442, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0441\u043a. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0438\u0441\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u0417\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u0438\u043c\u0438\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 work_mem. \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u0435\u0433\u043e \u0434\u043e 800Mb \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c explain \u0435\u0449\u0435 \u0440\u0430\u0437.<\/p>\n<pre><code class=\"pgsql\">SET work_mem = '800MB'; EXPLAIN (ANALYZE) SELECT * FROM table_a ORDER BY column_x; Gather Merge  (cost=1394157.71..2374413.52 rows=8401606 width=368) (actual time=684.390..2073.879 rows=10081680 loops=1) Workers Planned: 2 Workers Launched: 2 -&gt;  Sort  (cost=1393157.69..1403659.70 rows=4200803 width=368) (actual time=639.491..819.908 rows=3360560 loops=3)       Sort Key: table_a.column_x       Sort Method: quicksort  Memory: 639232kB       Worker 0:  Sort Method: quicksort  Memory: 695053kB       Worker 1:  Sort Method: quicksort  Memory: 699096kB       -&gt;  Parallel Append  (cost=0.00..227469.94 rows=4200803 width=368) (actual time=0.037..279.005 rows=3360560 loops=3)             -&gt;  Seq Scan on table_a_1 table_a_1  (cost=0.00..0.00 rows=1 width=368) (actual time=0.008..0.008 rows=0 loops=1)   ... Planning Time: 5.054 ms Execution Time: 2252.396 ms<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0430\u0441\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u0438\u0441\u043a\u0430. \u041e\u0431 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u2014 <strong>Sort Method: quicksort\u00a0 Memory<\/strong>: 639232kB <br \/>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f work_mem \u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 work_mem. \u0412 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-443196","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/443196","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=443196"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/443196\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=443196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=443196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=443196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}