{"id":473299,"date":"2025-09-02T16:06:33","date_gmt":"2025-09-02T16:06:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=473299"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=473299","title":{"rendered":"<span>\u0412\u044b\u0431\u043e\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u0440\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c<\/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>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u0443 \u041c\u0430\u043a\u0441\u0438\u043c\u0430 \u0421\u0442\u0430\u0440\u043a\u043e\u0432\u0430 &#171;\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438&#187; \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 PG BootCamp Russia 2025, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0448\u043b\u0430 \u0432 \u0430\u043f\u0440\u0435\u043b\u0435 \u0432 \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433\u0435. \u0414\u043e\u043a\u043b\u0430\u0434 \u043c\u043e\u0436\u043d\u043e\u00a0<a href=\"https:\/\/tantorlabs.ru\/tpost\/nxubgv0tz1-osobennosti-opredeleniya-selektivnosti-i\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a>, \u0441\u043a\u0430\u0447\u0430\u0442\u044c\u00a0<a href=\"https:\/\/github.com\/PGBootCamp\/Russia_2025\/blob\/main\/T1-L5%20-%20Starkov%20-%20Peculiarities%20in%20determining%20selectivity%20and%20related%20query%20execution%20issues.pdf\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>, \u043f\u0430\u0442\u0447 \u043a \u0434\u043e\u043a\u043b\u0430\u0434\u0443 \u0432\u044b\u043b\u043e\u0436\u0435\u043d\u00a0<a href=\"https:\/\/github.com\/TantorLabs\/meetups\/blob\/main\/2025-04-10_Ekb\/Maxim%20Starkov%20-%20Problem%20of%20selectivity%20assessment\/v1-0001-Added-support-for-functional-dependency-ext-stats.patch\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043a\u043b\u0430\u0434 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u0435\u043d, \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0451\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043c: \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c (parameterized scan), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0442\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u044d\u0442\u0438\u0445 \u0442\u0435\u043c \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u0431\u0448\u0438\u0440\u043d\u0430 \u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u044b \u0436\u0435 \u0437\u0430\u043e\u0441\u0442\u0440\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/p>\n<p><strong>\u0421\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/strong>\u00a0\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432\u00a0\u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0432\u0435\u0434\u0443\u0449\u0438\u043c\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0438. \u0422\u0430\u043a\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u043d\u043e \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 1\u0421:ERP, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043e. \u041a\u0430\u043a \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442: \u043f\u043e\u0441\u043b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0421\u0423\u0411\u0414 PostgreSQL \u0447\u0430\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435. \u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0436\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441, \u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0434\u0432\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0441\u0442\u0440\u043e\u043a.<\/p>\n<pre><code class=\"sql\">drop table if exists wide_table; create table wide_table ( c1 int not null, c2 int not null, c3 int not null, c4 int not null, c5 int not null, c6 int not null, c7 int not null, c8 int not null, c9 int not null, c10 int not null, c11 char(1000) not null, c12 char(1000) not null); insert into wide_table select i % 3 as c1, (i + 1) % 101010 as c2, (i + 2) % 10101 as c3, (i + 3) % 5 as c4, (i + 4) % 13 as c5, (i + 5) % 17 as c6, (i + 6) % 19 as c7, (i) as c8, (i + 10) as c9, (i + 20) as c10, 'FOO' as c11, 'BAR' as c12 from generate_series(1,1000000) as i; -- Create wide unique index create unique index idx_wide on wide_table ( c1, c2, c3, c4, c5, c6, c7, c8, c11, c12); -- Create narrow non-unique index create index idx_narrow on wide_table (c1, c2, c3); -- Analyze table analyze wide_table; vacuum wide_table; -- Create table to store some of the data from the wide_table drop table tt1; create table tt1 ( c1 int not null, c2 int not null, c3 int not null, c4 int not null, c5 int not null, c6 int not null, c7 int not null, c8 int not null, c9 int not null, c10 int not null, c11 char(1000) not null, c12 char(1000) not null); -- Fill table with a random sample from the wide_table insert into tt1 select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12 from wide_table order by random() limit 1000; -- Analyze table analyze tt1; vacuum wide_table; \\timing on \\\\ \\pset pager off \\\\<\/code><\/pre>\n<p>\u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 tt1 \u0431\u044b\u043b\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043d\u043e \u044d\u0442\u043e \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u2014 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 wide_table \u0441\u0442\u0440\u043e\u043a \u0431\u044b\u043b\u043e 500 \u0442\u044b\u0441\u044f\u0447, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0437\u0430\u043c\u0435\u0442\u043d\u0430 \u043d\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0440\u0435\u043c \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d.<\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 idx_narrow, \u0435\u0441\u043b\u0438 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 idx_wide \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438?\u00a0\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0443\u043f\u0440\u043e\u0449\u0451\u043d: \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432 \u0443\u0437\u043a\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u0438 \u043e\u0431\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b.\u00a0\u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0443\u0437\u043a\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043e\u0437\u043d\u0430\u0447\u0430\u043b\u043e \u0431\u044b \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u00a0\u0418\u0437-\u0437\u0430 \u043e\u0431\u0449\u0438\u0445 \u0432\u0435\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445\u00a0\u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u041f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0431\u0435 \u043e\u0431\u044a\u0451\u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0437\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u2014 1 116 \u041c\u0431:<\/p>\n<pre><code>postgres=# \\dt+ wide*                                      List of relations  Schema |    Name    | Type  |  Owner   | Persistence | Access method |  Size   | Description --------+------------+-------+----------+-------------+---------------+---------+-------------  public | wide_table | table | postgres | permanent   | heap          | 1116 MB |<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432:  <\/p>\n<pre><code>postgres=# \\di+ idx*                                              List of relations  Schema |    Name    | Type  |  Owner   |   Table    | Persistence | Access method |   Size   | Description --------+------------+-------+----------+------------+-------------+---------------+----------+-------------  public | idx_narrow | index | postgres | wide_table | permanent   | btree         | 10080 kB |  public | idx_wide   | index | postgres | wide_table | permanent   | btree         | 108 MB   |<\/code><\/pre>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u043e 10 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 108 \u041c\u0431, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 9.6% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u043e 3 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 0.88% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 108 \u041c\u0431 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0447\u0438\u0442\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u043b\u043e\u043a\u043e\u0432 \u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 10 \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435.\u00a0<\/p>\n<p><strong>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439\u00a0\u0437\u0430\u043f\u0440\u043e\u0441:<\/strong><\/p>\n<pre><code class=\"bash\">explain (analyze, buffers, timing off) select  t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7,  t1.c8, t1.c9 + t2.c9, t1.c10 + t2.c10, t1.c11,  t1.c12 from wide_table as t1  inner join tt1 as t2 on t1.c1 = t2.c1 and t1.c2 = t2.c2  and t1.c3 = t2.c3 and t1.c4 = t2.c4 and t1.c5 = t2.c5 and t1.c6 = t2.c6  and t1.c7 = t2.c7 and t1.c8 = t2.c8 and t1.c11 = t2.c11 and t1.c12 = t2.c12  where t1.c11 = 'FOO';<\/code><\/pre>\n<p>\u0412 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 WHERE (\u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u044111) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 10 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043e\u0437\u0434\u0430\u043d \u0438\u043d\u0434\u0435\u043a\u0441 idx_wide. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 wide_table \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<h2>\u0417\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432<\/h2>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 (\u0434\u043e 10) \u043d\u0430 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 PostgreSQL \u0438 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f (\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430). \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 idx_narrow \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 1 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u043e 16,548 \u043c\u0441.<\/p>\n<p>\u041f\u043b\u0430\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"bash\">Nested Loop  (cost=0.42..7482.50 rows=1 width=1069) (actual rows=1000 loops=1)    Buffers: shared hit=8458    -&gt;  Seq Scan on tt1 t2  (cost=0.00..155.50 rows=1000 width=1069) (actual rows=1000 loops=1)          Filter: (c11 = 'FOO'::bpchar)          Buffers: shared hit=143    -&gt;  Index Scan using idx_narrow on wide_table t1  (cost=0.42..7.32 rows=1 width=1069) (actual rows=1 loops=1000)          Index Cond: ((c1 = t2.c1) AND (c2 = t2.c2) AND (c3 = t2.c3))          Filter: ((c11 = 'FOO'::bpchar) AND (t2.c4 = c4) AND (t2.c5 = c5) AND (t2.c6 = c6) AND (t2.c7 = c7) AND (t2.c8 = c8) AND (t2.c12 = c12))          Rows Removed by Filter: 4          Buffers: shared hit=8315  Planning Time: 0.257 ms  Execution Time: 15.917 ms (12 rows)  Time: 16,548 ms<\/code><\/pre>\n<h2>\u0417\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432<\/h2>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u00ab\u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e\u00bb \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c\u00a0 \u043b\u0443\u0447\u0448\u0435\u00a0&#171;\u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e&#187;\u00a0\u0437\u0430\u043f\u0440\u043e\u0441. \u0417\u0430\u043f\u0440\u0435\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<pre><code>update pg_index set indisvalid = false where indexrelid::regclass = 'idx_narrow'::regclass;<\/code><\/pre>\n<p>\u041f\u043b\u0430\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"bash\">Nested Loop  (cost=0.42..8468.51 rows=1 width=1069) (actual rows=1000 loops=1)    Buffers: shared hit=4143    -&gt;  Seq Scan on tt1 t2  (cost=0.00..155.50 rows=1000 width=1069) (actual rows=1000 loops=1)          Filter: (c11 = 'FOO'::bpchar)          Buffers: shared hit=143    -&gt;  Index Scan using idx_wide on wide_table t1  (cost=0.42..8.31 rows=1 width=1069) (actual rows=1 loops=1000)          Index Cond: ((c1 = t2.c1) AND (c2 = t2.c2) AND (c3 = t2.c3) AND (c4 = t2.c4) AND (c5 = t2.c5) AND (c6 = t2.c6) AND (c7 = t2.c7) AND (c8 = t2.c8) AND (c11 = 'FOO'::bpchar) AND (c12 = t2.c12))          Buffers: shared hit=4000  Planning Time: 0.240 ms  Execution Time: 12.350 ms (10 rows)  Time: 12,939 ms<\/code><\/pre>\n<p>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c: \u0441 16,548 ms \u0434\u043e 12,939 ms. \u0427\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043b\u0430\u043d\u044b, \u043a\u0440\u043e\u043c\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f?<\/p>\n<ol>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u2014\u00a0<strong>idx_wide<\/strong>\u00a0\u0438\u00a0<strong>idx_narrow;<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432: shared hit=<strong>4000<\/strong>\u00a0\u0438 shared hit=<strong>8315;<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u043d\u0438\u0442\u0441\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430: cost=<strong>8.31<\/strong>\u00a0\u0438 cost=<strong>7.32.<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0447\u0442\u0435\u043d\u0438\u044f \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446.<\/p>\n<h2>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u0440\u043e\u043a<\/h2>\n<p>\u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u0440\u043e\u043a \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 \u0434\u043b\u044f \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 2 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow (cost=0.43..7.68 rows=1) hit=13737 Time: 26,675 ms Index Scan using idx_wide (cost=0.55..8.52 rows=1) hit=5000 Time: 13,858 ms<\/code><\/pre>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 5 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow (cost=0.43..8.13 rows=1) hit=38147 Time: 76,406 ms Index Scan using idx_wide \u00a0\u00a0(cost=0.56..8.57 rows=1) hit=5000 Time: 14,390 ms<\/code><\/pre>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 20 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow(cost=0.44..8.37 rows=1) Buffers: shared hit=101133 Time: 194,901 ms Index Scan using idx_wide (cost=0.56..8.60 rows=1) Buffers: shared hit=5000 Time: 15,329 ms<\/code><\/pre>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 50 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow (cost=0.56..8.56 rows=1) Buffers: shared hit=9538 read=243299 Time: 1837,796 ms Index Scan using idx_wide (cost=0.56..8.61 rows=1) Buffers: shared hit=5000 Time: 15,493 ms<\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0443\u0437\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0440\u0430\u0441\u0442\u0451\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u043f\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u043c\u0443, \u043d\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 50 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u043e\u043d\u0430 \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u044f\u043b\u0430\u0441\u044c. \u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0438\u0436\u0435. \u0412\u043e\u043e\u0431\u0449\u0435, \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u0440\u044f\u043c\u043e, \u0430 \u043d\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438\u00a0 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0\u0422\u0430\u043a\u043e\u0435 \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u0440\u0430\u0441\u0447\u0451\u0442\u0435 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430.\u00a0<\/p>\n<p>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0447\u0438\u0441\u043b\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u0440\u0430\u0441\u0442\u0451\u0442, \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u044d\u0448\u0430, \u0438\u043d\u0430\u0447\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437.<\/p>\n<p>\u0425\u043e\u0442\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043d\u043e \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 (\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a) \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0443\u0437\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u043d\u0435 \u0434\u043e\u0433\u043d\u0430\u043b\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443. \u0415\u0441\u0442\u044c \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u044b, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c, \u0438\u043c\u0435\u044e\u0442 \u0438\u0437\u044a\u044f\u043d\u044b.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0432\u0441\u0435 \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u044b \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0443\u0437\u043a\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c.\u00a0\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u043f\u0430\u0441\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0440\u0435\u0437\u043a\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442.\u00a0\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 20 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 50 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u044d\u0448\u0430 \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c, \u0438\u00a0<strong>\u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 100 \u0440\u0430\u0437 (\u043d\u0430 \u0434\u0432\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0430).<\/strong><\/p>\n<p>\u041d\u0430 \u0421\u0423\u0411\u0414 Tantor Postgres SE 17.5, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0430\u0442\u0447\u0443 \u041c\u0430\u043a\u0441\u0438\u043c\u0430 \u0421\u0442\u0430\u0440\u043a\u043e\u0432\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<pre><code class=\"bash\">Nested Loop  (cost=0.42..8480.51 rows=1 width=1074) (actual rows=1000 loops=1)    Buffers: shared hit=4143    -&gt;  Seq Scan on tt1 t2  (cost=0.00..155.50 rows=1000 width=1074) (actual rows=1000 loops=1)          Filter: (c11 = 'FOO'::bpchar)          Buffers: shared hit=143    -&gt;  Index Scan using idx_wide on wide_table t1  (cost=0.42..8.33 rows=1 width=1074) (actual rows=1 loops=1000)          Index Cond: ((c1 = t2.c1) AND (c2 = t2.c2) AND (c3 = t2.c3) AND (c4 = t2.c4) AND (c5 = t2.c5) AND (c6 = t2.c6) AND (c7 = t2.c7) AND (c8 = t2.c8) AND (c11 = 'FOO'::bpchar) AND (c12 = t2.c12))          Buffers: shared hit=4000  Planning Time: 0.779 ms  Execution Time: 12.238 ms (10 rows)  Time: 13.469 ms<\/code><\/pre>\n<p>\u041f\u0430\u0442\u0447 \u041c\u0430\u043a\u0441\u0438\u043c\u0430 \u0421\u0442\u0430\u0440\u043a\u043e\u0432\u0430 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u0430\u0442\u0447\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u0434\u043e\u043a\u043b\u0430\u0434\u0430: \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 750 \u0441\u0442\u0440\u043e\u043a, \u0438 \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430. \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0430\u0442\u0447\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043f\u0443\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0431\u043e\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043b\u0443\u0447\u0448\u0435\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438:<\/p>\n<ul>\n<li>\n<p>\u043a\u043b\u044e\u0447\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0442\u0430\u043a\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438\/\u0438\u043b\u0438 \u043e\u0442\u0431\u043e\u0440\u0430, \u0430 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#171;=&#187;;<\/p>\n<\/li>\n<li>\n<p>\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u0438\u0445 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438 \u0442\u0430\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u043e\u0439 \u2014 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0438\u0445 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438. \u0418\u043d\u0434\u0435\u043a\u0441 \u0441 \u043b\u0443\u0447\u0448\u0435\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442.<\/p>\n<h2>\u041f\u043e\u0434\u0441\u0447\u0451\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/h2>\n<p>\u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0435\u0441\u0442\u044c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 btcostestimate(..) \u0444\u0430\u0439\u043b\u0430 selfunc.c<\/p>\n<p>\u0412 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u044f\u0442:<\/p>\n<p>1) Index leaf pages cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u043c \u0431\u043b\u043e\u043a\u0430\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u0432 (\u0432 \u043f\u043b\u0430\u043d\u0435 Index Cond). \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f IO \u0438 CPU.<\/p>\n<p>\u0424\u043e\u0440\u043c\u0443\u043b\u044b \u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u043e\u0433\u043e, \u0432 \u043a\u0430\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043e\u0448\u0438\u0431\u0430\u0435\u0442\u0441\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0443\u043b\u0435.<\/p>\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f IO \u2014\u00a0\u0447\u0438\u0441\u043b\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0432\u043d\u043e\u0441\u0438\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0443\u0437\u043a\u043e\u0433\u043e \u0438 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<pre><code class=\"bash\">indexSelectivity * relpages  * num_scans (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435=1000) * random_page_cost<\/code><\/pre>\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f CPU:  <\/p>\n<pre><code class=\"bash\">reltuples  * cpu_operator_cost + cpu_index_tuple_cost<\/code><\/pre>\n<p>effective_cache_size \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430.  <\/p>\n<p>2) Index traversal (descent) cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u0434\u0435\u0440\u0435\u0432\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0434\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432. \u0417\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0447\u0438\u0441\u043b\u0430 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445, \u0442\u043e IO \u043d\u0435 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e CPU.  <\/p>\n<pre><code class=\"bash\">ceil(log(\u0441\u0442\u0440\u043e\u043a \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435) \/ log(2.0)) * cpu_operator_cost;<\/code><\/pre>\n<p>\u043f\u043b\u044e\u0441<\/p>\n<pre><code class=\"bash\">(level + 1) * (DEFAULT_PAGE_CPU_MULTIPLIER=50) * cpu_operator_cost;<\/code><\/pre>\n<p>\u0427\u0438\u0441\u043b\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0434\u043b\u044f 1 \u043c\u043b\u043d. \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0443 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 4 (level=3), \u0443 \u0443\u0437\u043a\u043e\u0433\u043e 3 (level=2):<\/p>\n<pre><code>create extension if not exists pageinspect; select fastroot,level from bt_metap('idx_wide'); select fastroot,level from bt_metap('idx_narrow');  fastroot | level ----------+-------     19615 |     3  fastroot | level ----------+-------       290 |     2<\/code><\/pre>\n<p>\u041d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043d\u0443\u043b\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u043c\u0443 \u0431\u043b\u043e\u043a\u0443 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f level+1 \u0431\u043b\u043e\u043a\u043e\u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0427\u0438\u0441\u043b\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0440\u0430\u0441\u0442\u0451\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.\u00a0\u042d\u0442\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u0432\u043d\u043e\u0441\u0438\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u043a\u043b\u0430\u0434 \u0432 \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043b\u0430\u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>3) Heap pages cost \u2014 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0431\u043b\u043e\u043a\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441, \u043d\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 WHERE. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f IO \u0438 CPU.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/64b\/6e5\/960\/64b6e59601534ed01be8617e321d7a64.jpg\" alt=\"\u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0434\u043b\u044f Heap pages cost, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f IO  \" title=\"\u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0434\u043b\u044f Heap pages cost, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f IO  \" width=\"1361\" height=\"704\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/64b\/6e5\/960\/64b6e59601534ed01be8617e321d7a64.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/64b\/6e5\/960\/64b6e59601534ed01be8617e321d7a64.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0434\u043b\u044f Heap pages cost, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f IO  <\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u043d\u0430\u00a0500 \u0442\u044b\u0441\u044f\u0447\u00a0\u0441\u0442\u0440\u043e\u043a cost=6.93 \u0434\u043b\u044f \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 cost=8.17 \u0434\u043b\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e. \u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0432\u043d\u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0432\u043a\u043b\u0430\u0434 \u0432 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c: <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/633\/0cf\/e40\/6330cfe40a8eb4da5f841d02b6a3f9f4.png\" alt=\"\u0420\u0430\u0441\u0447\u0435\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u043c PostgreSQL  \" title=\"\u0420\u0430\u0441\u0447\u0435\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u043c PostgreSQL  \" width=\"1421\" height=\"899\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/633\/0cf\/e40\/6330cfe40a8eb4da5f841d02b6a3f9f4.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/633\/0cf\/e40\/6330cfe40a8eb4da5f841d02b6a3f9f4.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0420\u0430\u0441\u0447\u0435\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u043c PostgreSQL  <\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u043a\u043b\u0430\u0434 \u0432 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u043d\u043e\u0441\u0438\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u043b\u043e\u043a\u0430\u043c (IO cost). Index leaf pages cost \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0448\u0438\u0440\u043e\u043a\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432. \u0412 Heap pages cost \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u043e\u0431\u043e\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<h2>\u041b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/h2>\n<p>\u0412 \u0437\u0430\u043f\u0438\u0441\u0438 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 10 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0428\u0438\u0440\u043e\u043a\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0440\u0430\u0437\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043f\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u043d \u0431\u043b\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0447\u0438\u0442\u0430\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435, \u043d\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<pre><code>\\pset xheader_width column \\\\ Expanded header width is \"column\". postgres=# select * from bt_page_items('idx_wide',100)  offset 1 fetch next 1 rows only\\gx -[ RECORD 1 ] itemoffset | 2 ctid       | (129926,1) itemlen    | 104 nulls      | f vars       | t data       | 00 00 00 00 8a 01 00 00 8b 01 00 00 01 00 00 00 07 00 00 00 05 00 00 00 10 00 00 00 ab e0 0d 00 7a 00 00 00 e8 03 00 00 f0 46 4f 4f 20 0f 01 ff 0f 01 ff 0f 01 ff 0f 01 9b 00 20 20 20 20 00 00 7a 00 00 00 e8 03 00 00 f0 42 41 52 20 0f 01 ff 0f 01 ff 0f 01 ff 0f 01 9b 00 20 20 20 20 00 00 dead       | f htid       | (129926,1) tids       |<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 data \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 10 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0412 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 ctid \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0431\u043b\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b (129926) \u0438 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u0430\u0434\u0440\u0435\u0441 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435 (1).<\/p>\n<p>\u041e\u0433\u043e\u0432\u043e\u0440\u043a\u0430 \u043f\u0440\u043e \u043c\u043d\u043e\u0433\u043e\u0432\u0435\u0440\u0441\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u044c. \u0412 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043c\u0451\u0440\u0442\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0443\u0437\u043a\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0435. \u041f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u043e\u0431\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u043e\u0433\u043e\u0432\u0435\u0440\u0441\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043e\u0431\u043e\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e.<\/p>\n<p>\u0412 \u0443\u0437\u043a\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b\u00a0\u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043c\u043d\u043e\u0433\u043e \u043b\u0438 \u0438\u0445:<\/p>\n<pre><code>select * from bt_page_items('idx_narrow',100)  offset 1 fetch next 1 rows only\\gx -[ RECORD 1 ] itemoffset | 2 ctid       | (24,8242) itemlen    | 328 nulls      | f vars       | f data       | 00 00 00 00 48 19 00 00 49 19 00 00 00 00 00 00 dead       | f htid       | (924,3) tids       | {\"(924,3)\",\"(15354,3)\",\"(29784,3)\",\"(44214,3)\",\"(58644,3)\",\"(73074,3)\",\"(87504,3)\",\"(101934,3)\",\"(116364,3)\",\"(130794,3)\",\"(145224,3)\",\"(159654,3)\",\"(174084,3)\",\"(188514,3)\",\"(202944,3)\",\"(217374,3)\",\"(231804,3)\",\"(246234,3)\",\"(260664,3)\",\"(275094,3)\",\"(289524,3)\",\"(303954,3)\",\"(318384,3)\",\"(332814,3)\",\"(347244,3)\",\"(361674,3)\",\"(376104,3)\",\"(390534,3)\",\"(404964,3)\",\"(419394,3)\",\"(433824,3)\",\"(448254,3)\",\"(462684,3)\",\"(477114,3)\",\"(491544,3)\",\"(505974,3)\",\"(520404,3)\",\"(534834,3)\",\"(549264,3)\",\"(563694,3)\",\"(578124,3)\",\"(592554,3)\",\"(606984,3)\",\"(621414,3)\",\"(635844,3)\",\"(650274,3)\",\"(664704,3)\",\"(679134,3)\",\"(693564,3)\",\"(707994,3)\"}<\/code><\/pre>\n<p>\u0412\u0437\u044f\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 100.<strong>\u00a0<\/strong>\u0427\u0438\u0441\u043b\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 (\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445) \u0431\u043b\u043e\u043a\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u044b \u043d\u0430\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0439 \u0431\u043b\u043e\u043a. \u0412 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 data \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0451\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043e\u0437\u0434\u0430\u043d \u0438\u043d\u0434\u0435\u043a\u0441. \u0412 \u0441\u0442\u043e\u043b\u0431\u0446\u0435\u00a0<code>tids<\/code>\u00a0\u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0451\u0445 \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0431\u043b\u043e\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435. \u0411\u043b\u043e\u043a\u043e\u0432 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u2014 50. \u0411\u0443\u0434\u0435\u0442 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 50 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.\u00a0\u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0443\u0437\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 (\u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 1 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u2014 Buffers: shared hit=8315) \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u2014 \u043e\u043a\u043e\u043b\u043e 4000 \u0431\u0443\u0444\u0435\u0440\u043e\u0432. \u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 2 \u0440\u0430\u0437\u0430, \u0447\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0432 50 \u0440\u0430\u0437.<\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0440\u0430\u0441\u0442\u0451\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u042d\u0442\u043e, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0432\u0441\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0447\u0438\u0442\u0430\u043d\u044b \u0432 \u0431\u0443\u0444\u0435\u0440\u043d\u044b\u0439 \u043a\u044d\u0448.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0436\u0435 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0447\u0438\u0441\u043b\u043e \u0431\u043b\u043e\u043a\u043e\u0432 \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f.<\/p>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>\u0434\u043b\u044f 2 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435: Index Scan using idx_narrow Buffers: shared hit=13737 Time: 26,675 ms  Index Scan using idx_wide Buffers: shared hit=5000 Time: 13,858 ms  \u0434\u043b\u044f 5 \u043c\u043b\u043d: Index Scan using idx_narrow Buffers: shared hit=38147 Time: 76,406 ms  Index Scan using idx_wide   Buffers: shared hit=5000 Time: 14,390 ms  \u0434\u043b\u044f 20 \u043c\u043b\u043d: Index Scan using idx_narrow Buffers: shared hit=101133 Time: 194,901 ms  Index Scan using idx_wide Buffers: shared hit=5000 Time: 15,329 ms  Buffers: shared 101133 \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u044d\u0442\u043e 790\u041c\u0431 \u0432 \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u043c \u043a\u044d\u0448\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0431\u0443\u0444\u0435\u0440\u043d\u044b\u0439 \u043a\u044d\u0448 \u0441 128\u041c\u0431 \u0434\u043e 1\u0413\u0431. \u0411\u0435\u0437 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u044b\u043b\u043e \u0431\u044b \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435.  \u0434\u043b\u044f 50 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435: Index Scan using idx_narrow Buffers: shared hit=9538 read=243299 Time: 1837,796 ms  Index Scan using idx_wide Buffers: shared hit=5000 Time: 15,493 ms  \u0414\u043b\u044f 50 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u043b\u043e \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u044d\u0448\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 1 \u0413\u0431.<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 2 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow Buffers: shared hit=13737 Time: 26,675 ms Index Scan using idx_wide Buffers: shared hit=5000 Time: 13,858 ms<\/code><\/pre>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 5 \u043c\u043b\u043d.:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow Buffers: shared hit=38147 Time: 76,406 ms Index Scan using idx_wide   Buffers: shared hit=5000 Time: 14,390 ms<\/code><\/pre>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 20 \u043c\u043b\u043d.:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow Buffers: shared hit=101133 Time: 194,901 ms Index Scan using idx_wide Buffers: shared hit=5000 Time: 15,329 ms<\/code><\/pre>\n<p>Buffers: shared 101133 \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u044d\u0442\u043e 790\u041c\u0431 \u0432 \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u043c \u043a\u044d\u0448\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0431\u0443\u0444\u0435\u0440\u043d\u044b\u0439 \u043a\u044d\u0448 \u0441 128\u041c\u0431 \u0434\u043e 1\u0413\u0431. \u0411\u0435\u0437 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u044b\u043b\u043e \u0431\u044b \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435.  <\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 50 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow Buffers: shared hit=9538 read=243299 Time: 1837,796 ms Index Scan using idx_wide Buffers: shared hit=5000 Time: 15,493 ms<\/code><\/pre>\n<p>\u0414\u043b\u044f 50 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u043b\u043e \u0431\u0443\u0444\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u044d\u0448\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 1 \u0413\u0431.<\/p>\n<h2>Heap\u00a0pages\u00a0cost<\/h2>\n<p>\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c Heap pages cost \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430 \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0430 \u044d\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u043e. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043b\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0414\u043b\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u043d\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0414\u043b\u044f \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0441\u0442\u0440\u043e\u043a, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0432 \u0434\u0435\u0441\u044f\u0442\u043a\u0430\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>\u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u043d\u0430 \u0441\u043b\u0430\u0439\u0434\u0430\u0445 22\u201324 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u2014 \u043e\u043d\u0430 \u0441\u043b\u043e\u0436\u043d\u0430, \u0438 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0435\u0451 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c. \u0412 \u043d\u0435\u0451 \u0432\u0445\u043e\u0434\u044f\u0442 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 random_page_cost, \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0439 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043b\u0438 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u041a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f pg_stats.correlation \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u043e\u0431\u043e\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u043e\u0439 \u0434\u043b\u044f \u0443\u0437\u043a\u043e\u0433\u043e \u0438 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u0442\u043e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u0430 \u0434\u043b\u044f \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0441\u044f \u043d\u0430 14.4648:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1b9\/a0c\/e5d\/1b9a0ce5d3fb93bd67824dad75b31319.png\" alt=\"\u0412 IO-\u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 Heap pages cost \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b  \" title=\"\u0412 IO-\u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 Heap pages cost \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b  \" width=\"728\" height=\"170\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1b9\/a0c\/e5d\/1b9a0ce5d3fb93bd67824dad75b31319.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1b9\/a0c\/e5d\/1b9a0ce5d3fb93bd67824dad75b31319.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412 IO-\u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 Heap pages cost \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b  <\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0430\u0442\u0447 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0446\u0435\u043d\u043a\u0443 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043f\u043e \u0443\u0437\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 (+14.4648). \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0443\u0437\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0434\u043e 21.5 \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u043d, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 8.1705.<\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435\u00a0selfuncs.s\u00a0\u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435: &#171;clauselist_selectivity() is easily fooled into computing a too-low selectivity estimate&#187;. \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u0430\u0451\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u0432 \u0432 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445, \u043d\u043e \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u043e \u0432\u0435\u0440\u043d\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439, \u0433\u0434\u0435 \u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439 (\u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u0432), \u0441\u043e\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c AND.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043f\u043e\u0439\u043b\u0435\u0440<\/summary>\n<div class=\"spoiler__content\">\n<p><code>ANDing the index predicate with the explicitly given indexquals produces<\/code><\/p>\n<ul>\n<li>\n<p><code>a more accurate idea of the index's selectivity.  However, we need to be<\/code><\/p>\n<\/li>\n<li>\n<p><code>careful not to insert redundant clauses, because clauselist_selectivity()<\/code><\/p>\n<\/li>\n<li>\n<p><code>is easily fooled into computing a too-low selectivity estimate.  Our<\/code><\/p>\n<\/li>\n<li>\n<p><code>approach is to add only the predicate clause(s) that cannot be proven to<\/code><\/p>\n<\/li>\n<li>\n<p><code>be implied by the given indexquals.  This successfully handles cases such<\/code><\/p>\n<\/li>\n<li>\n<p><code>as a qual \"x = 42\" used with a partial index \"WHERE x &gt;= 40 AND x &lt; 50\".<\/code><\/p>\n<\/li>\n<li>\n<p><code>There are many other cases where we won't detect redundancy, leading to a<\/code><\/p>\n<\/li>\n<li>\n<p><code>too-low selectivity estimate, which will bias the system in favor of using<\/code><\/p>\n<\/li>\n<li>\n<p><code>partial indexes where possible.<\/code><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<p>\u0412 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 11 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u0430\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 500 \u0442\u044b\u0441 \u0441\u0442\u0440\u043e\u043a \u0434\u043b\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 3e-20, \u0434\u043b\u044f \u0443\u0437\u043a\u043e\u0433\u043e \u2014 3e-10. \u0427\u0438\u0441\u043b\u0430 \u0437\u0430\u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 (\u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435) \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u0437\u0432\u0443\u0447\u0430\u043b\u043e \u043a\u0430\u043a &#171;\u0417\u0430\u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c&#187;.<\/p>\n<p>\u0421\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u00a0AND\u00a0\u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 clauselist_selectivity_ext(PlannerInfo..) \u0444\u0430\u0439\u043b\u0430\u00a0clausesel.c<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u044b, \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f, \u0430 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 11 \u0447\u0438\u0441\u0435\u043b \u0434\u0430\u0451\u0442 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043d\u0438\u0437\u043a\u0443\u044e \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c. \u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c \u0441\u0442\u0440\u043e\u043a:<\/p>\n<pre><code>select attname, correlation, n_distinct from pg_stats where tablename='wide_table';  attname | correlation | n_distinct ---------+-------------+------------  c1      |           1 |          3  c2      |  0.33610082 |      38708  c3      | 0.042892195 |       9640  c4      |  0.19834672 |          5  c5      | 0.086536884 |         13  c6      | 0.051232968 |         17  c7      | 0.046109326 |         19  c8      | 0.021048114 |         -1  c9      | 0.021048114 |         -1  c10     | 0.021048114 |         -1  c11     |           1 |          1  c12     |           1 |          1<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f n_distinct, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e 2e13 \u0438 \u0437\u0430\u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u0430\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c 4e-14.  <\/p>\n<p>\u0420\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c:<\/p>\n<pre><code>select count(distinct c1) c1_nd, count(distinct c2) c2_nd, count(distinct c3) c3_nd, count(distinct c4) c4_nd, count(distinct c5) c5_nd, count(distinct c6) c6_nd, count(distinct c7) c7_nd, count(distinct c8) c8_nd, count(distinct c9) c9_nd, count(distinct c11) c11_nd from wide_table;  c1_nd | c2_nd  | c3_nd | c4_nd | c5_nd | c6_nd | c7_nd |  c8_nd  |  c9_nd  | c11_nd -------+--------+-------+-------+-------+-------+-------+---------+---------+--------      3 | 101010 | 10101 |     5 |    13 |    17 |    19 | 1000000 | 1000000 |      1<\/code><\/pre>\n<p>\u041f\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u0443 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e 38\u202f708, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 101\u202f010 (\u0441\u0442\u043e \u043e\u0434\u043d\u0430 \u0442\u044b\u0441\u044f\u0447\u0430 \u0434\u0435\u0441\u044f\u0442\u044c). \u0422\u0435\u043c\u0430 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u043a\u0438 \u0447\u0438\u0441\u043b\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439\u00a0<a href=\"https:\/\/tantorlabs.ru\/tpost\/b2ngkkclc1-glaznie-kapli-dlya-postgres-ili-kak-povi\" rel=\"noopener noreferrer nofollow\">\u0431\u044b\u043b\u0430 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430<\/a>\u00a0\u043d\u0430 \u044d\u0442\u043e\u0439 \u0436\u0435 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 PG BootCamp Russia 2025 \u0410\u0440\u0442\u0435\u043c\u043e\u043c \u0411\u0443\u0433\u0430\u0435\u043d\u043a\u043e (\u043a\u043e\u043b\u043b\u0435\u0433\u043e\u0439 \u041c\u0430\u043a\u0441\u0438\u043c\u0430 \u0421\u0442\u0430\u0440\u043a\u043e\u0432\u0430).\u00a0<em>\u0420\u0443\u0447\u043d\u0430\u044f\u00a0<\/em>\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 n_distinct) \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u00a0<a href=\"https:\/\/youtu.be\/VlmIIYzVNyU\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u043b\u0430\u0434\u0435<\/a>\u00a0\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u0430 \u041d\u0438\u043a\u0438\u0442\u0438\u043d\u0430 &#171;\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f DBA&#187;.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u043a\u0430 \u0447\u0438\u0441\u043b\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439, \u043e\u0434\u043d\u0430\u043a\u043e \u0438\u0437-\u0437\u0430 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u0430\u0436\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u043a\u0430 \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443.<\/p>\n<p>\u0427\u0438\u0441\u043b\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u043f\u0435\u0440\u0432\u044b\u043c \u0442\u0440\u0435\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c:<\/p>\n<pre><code>select count(1) idx_narrow_key_n_distinct from (select distinct c1, c2, c3 from wide_table);  idx_narrow_key_n_distinct ---------------------------                     101010<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c 1\/101010 \u0431\u044b\u043b\u0430 \u0431\u044b \u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u043e\u0439. \u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 PostgreSQL (\/src\/backend\/optimizer\/path\/clausesel.c): \u00ab\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043a \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435. \u041e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u0451\u043c \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0445 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0435\u0439, \u043d\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0440\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u0430 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u041d\u0415 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c\u0438, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0431\u044b\u0442\u044c \u0443\u043c\u043d\u0435\u0435 \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u00bb.  <\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043f\u043e\u0439\u043b\u0435\u0440<\/summary>\n<div class=\"spoiler__content\">\n<ul>\n<li>\n<p><code>The basic approach is to apply extended statistics first, on as many<\/code><\/p>\n<\/li>\n<li>\n<p><code>clauses as possible,<\/code>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 dependencies \u0438 ndistinct \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438 \u043e\u0446\u0435\u043d\u043a\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0445 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0439, \u0438 \u043f\u0430\u0442\u0447 \u0438\u0437 \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 dependencies.  <code> in order to capture cross-column dependencies etc.<\/code><\/p>\n<\/li>\n<li>\n<p><code>The remaining clauses are then estimated by taking the product of their<\/code><\/p>\n<\/li>\n<li>\n<p><code>selectivities, but that's only right if they have independent<\/code><\/p>\n<\/li>\n<li>\n<p><code>probabilities, and in reality they are often NOT independent even if they<\/code><\/p>\n<\/li>\n<li>\n<p><code>only refer to a single column.  So, we want to be smarter where we can.<\/code><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<p>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 dependencies \u0438 ndistinct \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438 \u043e\u0446\u0435\u043d\u043a\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0445 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0439, \u0438 \u043f\u0430\u0442\u0447 \u0438\u0437 \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 dependencies.<\/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\/930602\/\"> https:\/\/habr.com\/ru\/articles\/930602\/<\/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>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u0443 \u041c\u0430\u043a\u0441\u0438\u043c\u0430 \u0421\u0442\u0430\u0440\u043a\u043e\u0432\u0430 &#171;\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438&#187; \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 PG BootCamp Russia 2025, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0448\u043b\u0430 \u0432 \u0430\u043f\u0440\u0435\u043b\u0435 \u0432 \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0431\u0443\u0440\u0433\u0435. \u0414\u043e\u043a\u043b\u0430\u0434 \u043c\u043e\u0436\u043d\u043e\u00a0<a href=\"https:\/\/tantorlabs.ru\/tpost\/nxubgv0tz1-osobennosti-opredeleniya-selektivnosti-i\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/a>, \u0441\u043a\u0430\u0447\u0430\u0442\u044c\u00a0<a href=\"https:\/\/github.com\/PGBootCamp\/Russia_2025\/blob\/main\/T1-L5%20-%20Starkov%20-%20Peculiarities%20in%20determining%20selectivity%20and%20related%20query%20execution%20issues.pdf\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>, \u043f\u0430\u0442\u0447 \u043a \u0434\u043e\u043a\u043b\u0430\u0434\u0443 \u0432\u044b\u043b\u043e\u0436\u0435\u043d\u00a0<a href=\"https:\/\/github.com\/TantorLabs\/meetups\/blob\/main\/2025-04-10_Ekb\/Maxim%20Starkov%20-%20Problem%20of%20selectivity%20assessment\/v1-0001-Added-support-for-functional-dependency-ext-stats.patch\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043a\u043b\u0430\u0434 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u0435\u043d, \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0451\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043c: \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c (parameterized scan), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0442\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u044d\u0442\u0438\u0445 \u0442\u0435\u043c \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u0431\u0448\u0438\u0440\u043d\u0430 \u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u044b \u0436\u0435 \u0437\u0430\u043e\u0441\u0442\u0440\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/p>\n<p><strong>\u0421\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/strong>\u00a0\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432\u00a0\u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0432\u0435\u0434\u0443\u0449\u0438\u043c\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0438. \u0422\u0430\u043a\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u043d\u043e \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 1\u0421:ERP, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043e. \u041a\u0430\u043a \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442: \u043f\u043e\u0441\u043b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0421\u0423\u0411\u0414 PostgreSQL \u0447\u0430\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435. \u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0436\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441, \u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0434\u0432\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0441\u0442\u0440\u043e\u043a.<\/p>\n<pre><code class=\"sql\">drop table if exists wide_table; create table wide_table ( c1 int not null, c2 int not null, c3 int not null, c4 int not null, c5 int not null, c6 int not null, c7 int not null, c8 int not null, c9 int not null, c10 int not null, c11 char(1000) not null, c12 char(1000) not null); insert into wide_table select i % 3 as c1, (i + 1) % 101010 as c2, (i + 2) % 10101 as c3, (i + 3) % 5 as c4, (i + 4) % 13 as c5, (i + 5) % 17 as c6, (i + 6) % 19 as c7, (i) as c8, (i + 10) as c9, (i + 20) as c10, 'FOO' as c11, 'BAR' as c12 from generate_series(1,1000000) as i; -- Create wide unique index create unique index idx_wide on wide_table ( c1, c2, c3, c4, c5, c6, c7, c8, c11, c12); -- Create narrow non-unique index create index idx_narrow on wide_table (c1, c2, c3); -- Analyze table analyze wide_table; vacuum wide_table; -- Create table to store some of the data from the wide_table drop table tt1; create table tt1 ( c1 int not null, c2 int not null, c3 int not null, c4 int not null, c5 int not null, c6 int not null, c7 int not null, c8 int not null, c9 int not null, c10 int not null, c11 char(1000) not null, c12 char(1000) not null); -- Fill table with a random sample from the wide_table insert into tt1 select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12 from wide_table order by random() limit 1000; -- Analyze table analyze tt1; vacuum wide_table; \\timing on \\\\ \\pset pager off \\\\<\/code><\/pre>\n<p>\u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 tt1 \u0431\u044b\u043b\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043d\u043e \u044d\u0442\u043e \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u2014 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 wide_table \u0441\u0442\u0440\u043e\u043a \u0431\u044b\u043b\u043e 500 \u0442\u044b\u0441\u044f\u0447, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0437\u0430\u043c\u0435\u0442\u043d\u0430 \u043d\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0440\u0435\u043c \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d.<\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 idx_narrow, \u0435\u0441\u043b\u0438 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 idx_wide \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438?\u00a0\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0443\u043f\u0440\u043e\u0449\u0451\u043d: \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432 \u0443\u0437\u043a\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u0438 \u043e\u0431\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b.\u00a0\u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0443\u0437\u043a\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043e\u0437\u043d\u0430\u0447\u0430\u043b\u043e \u0431\u044b \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u00a0\u0418\u0437-\u0437\u0430 \u043e\u0431\u0449\u0438\u0445 \u0432\u0435\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445\u00a0\u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u041f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0431\u0435 \u043e\u0431\u044a\u0451\u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0437\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u2014 1 116 \u041c\u0431:<\/p>\n<pre><code>postgres=# \\dt+ wide*                                      List of relations  Schema |    Name    | Type  |  Owner   | Persistence | Access method |  Size   | Description --------+------------+-------+----------+-------------+---------------+---------+-------------  public | wide_table | table | postgres | permanent   | heap          | 1116 MB |<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432:  <\/p>\n<pre><code>postgres=# \\di+ idx*                                              List of relations  Schema |    Name    | Type  |  Owner   |   Table    | Persistence | Access method |   Size   | Description --------+------------+-------+----------+------------+-------------+---------------+----------+-------------  public | idx_narrow | index | postgres | wide_table | permanent   | btree         | 10080 kB |  public | idx_wide   | index | postgres | wide_table | permanent   | btree         | 108 MB   |<\/code><\/pre>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u043e 10 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 108 \u041c\u0431, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 9.6% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u043e 3 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 0.88% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 108 \u041c\u0431 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0447\u0438\u0442\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u043b\u043e\u043a\u043e\u0432 \u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 10 \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435.\u00a0<\/p>\n<p><strong>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439\u00a0\u0437\u0430\u043f\u0440\u043e\u0441:<\/strong><\/p>\n<pre><code class=\"bash\">explain (analyze, buffers, timing off) select  t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7,  t1.c8, t1.c9 + t2.c9, t1.c10 + t2.c10, t1.c11,  t1.c12 from wide_table as t1  inner join tt1 as t2 on t1.c1 = t2.c1 and t1.c2 = t2.c2  and t1.c3 = t2.c3 and t1.c4 = t2.c4 and t1.c5 = t2.c5 and t1.c6 = t2.c6  and t1.c7 = t2.c7 and t1.c8 = t2.c8 and t1.c11 = t2.c11 and t1.c12 = t2.c12  where t1.c11 = 'FOO';<\/code><\/pre>\n<p>\u0412 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 WHERE (\u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u044111) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 10 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043e\u0437\u0434\u0430\u043d \u0438\u043d\u0434\u0435\u043a\u0441 idx_wide. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 wide_table \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<h2>\u0417\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432<\/h2>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 (\u0434\u043e 10) \u043d\u0430 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 PostgreSQL \u0438 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f (\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430). \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 idx_narrow \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 1 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u043e 16,548 \u043c\u0441.<\/p>\n<p>\u041f\u043b\u0430\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"bash\">Nested Loop  (cost=0.42..7482.50 rows=1 width=1069) (actual rows=1000 loops=1)    Buffers: shared hit=8458    -&gt;  Seq Scan on tt1 t2  (cost=0.00..155.50 rows=1000 width=1069) (actual rows=1000 loops=1)          Filter: (c11 = 'FOO'::bpchar)          Buffers: shared hit=143    -&gt;  Index Scan using idx_narrow on wide_table t1  (cost=0.42..7.32 rows=1 width=1069) (actual rows=1 loops=1000)          Index Cond: ((c1 = t2.c1) AND (c2 = t2.c2) AND (c3 = t2.c3))          Filter: ((c11 = 'FOO'::bpchar) AND (t2.c4 = c4) AND (t2.c5 = c5) AND (t2.c6 = c6) AND (t2.c7 = c7) AND (t2.c8 = c8) AND (t2.c12 = c12))          Rows Removed by Filter: 4          Buffers: shared hit=8315  Planning Time: 0.257 ms  Execution Time: 15.917 ms (12 rows)  Time: 16,548 ms<\/code><\/pre>\n<h2>\u0417\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432<\/h2>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u00ab\u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e\u00bb \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c\u00a0 \u043b\u0443\u0447\u0448\u0435\u00a0&#171;\u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e&#187;\u00a0\u0437\u0430\u043f\u0440\u043e\u0441. \u0417\u0430\u043f\u0440\u0435\u0442\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<pre><code>update pg_index set indisvalid = false where indexrelid::regclass = 'idx_narrow'::regclass;<\/code><\/pre>\n<p>\u041f\u043b\u0430\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"bash\">Nested Loop  (cost=0.42..8468.51 rows=1 width=1069) (actual rows=1000 loops=1)    Buffers: shared hit=4143    -&gt;  Seq Scan on tt1 t2  (cost=0.00..155.50 rows=1000 width=1069) (actual rows=1000 loops=1)          Filter: (c11 = 'FOO'::bpchar)          Buffers: shared hit=143    -&gt;  Index Scan using idx_wide on wide_table t1  (cost=0.42..8.31 rows=1 width=1069) (actual rows=1 loops=1000)          Index Cond: ((c1 = t2.c1) AND (c2 = t2.c2) AND (c3 = t2.c3) AND (c4 = t2.c4) AND (c5 = t2.c5) AND (c6 = t2.c6) AND (c7 = t2.c7) AND (c8 = t2.c8) AND (c11 = 'FOO'::bpchar) AND (c12 = t2.c12))          Buffers: shared hit=4000  Planning Time: 0.240 ms  Execution Time: 12.350 ms (10 rows)  Time: 12,939 ms<\/code><\/pre>\n<p>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c: \u0441 16,548 ms \u0434\u043e 12,939 ms. \u0427\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043b\u0430\u043d\u044b, \u043a\u0440\u043e\u043c\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f?<\/p>\n<ol>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u2014\u00a0<strong>idx_wide<\/strong>\u00a0\u0438\u00a0<strong>idx_narrow;<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432: shared hit=<strong>4000<\/strong>\u00a0\u0438 shared hit=<strong>8315;<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u043d\u0438\u0442\u0441\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430: cost=<strong>8.31<\/strong>\u00a0\u0438 cost=<strong>7.32.<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0447\u0442\u0435\u043d\u0438\u044f \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446.<\/p>\n<h2>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u0440\u043e\u043a<\/h2>\n<p>\u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u0441\u0442\u0440\u043e\u043a \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 \u0434\u043b\u044f \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 2 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow (cost=0.43..7.68 rows=1) hit=13737 Time: 26,675 ms Index Scan using idx_wide (cost=0.55..8.52 rows=1) hit=5000 Time: 13,858 ms<\/code><\/pre>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 5 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow (cost=0.43..8.13 rows=1) hit=38147 Time: 76,406 ms Index Scan using idx_wide \u00a0\u00a0(cost=0.56..8.57 rows=1) hit=5000 Time: 14,390 ms<\/code><\/pre>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 20 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow(cost=0.44..8.37 rows=1) Buffers: shared hit=101133 Time: 194,901 ms Index Scan using idx_wide (cost=0.56..8.60 rows=1) Buffers: shared hit=5000 Time: 15,329 ms<\/code><\/pre>\n<ul>\n<li>\n<p>\u0434\u043b\u044f 50 \u043c\u043b\u043d. \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code>Index Scan using idx_narrow (cost=0.56..8.56 rows=1) Buffers: shared hit=9538 read=243299 Time: 1837,796 ms Index Scan using idx_wide (cost=0.56..8.61 rows=1) Buffers: shared hit=5000 Time: 15,493 ms<\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u0443\u0437\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0440\u0430\u0441\u0442\u0451\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u043f\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u043c\u0443, \u043d\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 50 \u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a \u043e\u043d\u0430 \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u044f\u043b\u0430\u0441\u044c. \u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0438\u0436\u0435. \u0412\u043e\u043e\u0431\u0449\u0435, \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u0440\u044f\u043c\u043e, \u0430 \u043d\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438\u00a0 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0\u0422\u0430\u043a\u043e\u0435 \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u0440\u0430\u0441\u0447\u0451\u0442\u0435 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430.\u00a0<\/p>\n<p>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0437\u043a\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0447\u0438\u0441\u043b\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u0440\u0430\u0441\u0442\u0451\u0442, \u0438<\/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-473299","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473299","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=473299"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473299\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=473299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=473299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}