{"id":460483,"date":"2025-05-22T09:00:19","date_gmt":"2025-05-22T09:00:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=460483"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=460483","title":{"rendered":"<span>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445 PostgreSQL \u0438\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u043e ESR<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 B-tree \u0438\u043d\u0434\u0435\u043a\u0441, \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e &#171;\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441&#187;, \u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u2014 \u0438\u043d\u0430\u0447\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c\u0441\u044f, \u043d\u043e \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e? \u0411\u0440\u0443\u0442\u0444\u043e\u0440\u0441\u043e\u043c? \u041f\u043e \u0438\u043d\u0442\u0443\u0438\u0446\u0438\u0438? \u041f\u043e \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438? <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432 PostgreSQL, \u043d\u0430 \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a. \u0422\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e ESR, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0432\u044b\u0431\u043e\u0440 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u0442\u0435\u043d\u0434\u0430\u0445.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/94d\/f2d\/0f0\/94df2d0f0013dc728b921ea23ad0f016.jpg\" alt=\"\u041b\u0435\u043e\u043d\u0430\u0440\u0434 \u042d\u0439\u043b\u0435\u0440 - \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0441\u043a\u0438\u0445 \u043c\u043e\u0441\u0442\u0430\u0445\" title=\"\u041b\u0435\u043e\u043d\u0430\u0440\u0434 \u042d\u0439\u043b\u0435\u0440 - \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0441\u043a\u0438\u0445 \u043c\u043e\u0441\u0442\u0430\u0445\" width=\"4672\" height=\"6040\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/94d\/f2d\/0f0\/94df2d0f0013dc728b921ea23ad0f016.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/94d\/f2d\/0f0\/94df2d0f0013dc728b921ea23ad0f016.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%AD%D0%B9%D0%BB%D0%B5%D1%80,_%D0%9B%D0%B5%D0%BE%D0%BD%D0%B0%D1%80%D0%B4#\" rel=\"noopener noreferrer nofollow\">\u041b\u0435\u043e\u043d\u0430\u0440\u0434 \u042d\u0439\u043b\u0435\u0440<\/a> &#8212; \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%B4%D0%B0%D1%87%D0%B0_%D0%BE_%D1%81%D0%B5%D0%BC%D0%B8_%D0%BA%D1%91%D0%BD%D0%B8%D0%B3%D1%81%D0%B1%D0%B5%D1%80%D0%B3%D1%81%D0%BA%D0%B8%D1%85_%D0%BC%D0%BE%D1%81%D1%82%D0%B0%D1%85\" rel=\"noopener noreferrer nofollow\">\u043a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0441\u043a\u0438\u0445 \u043c\u043e\u0441\u0442\u0430\u0445<\/a><\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0434\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043e\u0442\u0441\u044b\u043b\u043a\u0443 \u043a \u0442\u0435\u043c\u0435 \u2014 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u042d\u0439\u043b\u0435\u0440\u0430 \u043a\u0430\u043a \u043f\u0435\u0440\u0432\u043e\u043f\u0440\u043e\u0445\u043e\u0434\u0446\u0430 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. <\/p>\n<\/div>\n<\/details>\n<p>\u042f \u2014 \u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0414\u0435\u043d\u0438\u0441\u0435\u043d\u043a\u043e, Sofware Developer. \u0425\u043e\u0447\u0443 \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0430\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.   <\/p>\n<hr\/>\n<h2>\u0412\u0432\u043e\u0434\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c &#8212; \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0438\u0441\u043a \u0432 B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0435<\/h2>\n<p>\u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0439\u043c\u0451\u043c, \u0447\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 B-tree \u0432 PostgreSQL. <\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/master\/src\/backend\/access\/nbtree\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434<\/a> \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b PostgreSQL, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u044f \u0445\u043e\u0447\u0443 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u0435, \u0430 \u043d\u0435 \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0434\u0435\u0431\u0440\u0438.  <\/p>\n<\/div>\n<\/details>\n<p>B-tree \u0438\u043b\u0438 \u0436\u0435 \u043c\u043d\u043e\u0433\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e (\u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 B \u0432 B-tree \u2014 \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043d\u0438\u043a\u0442\u043e: \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u0430\u043a <code>balanced<\/code>, <code>broad<\/code> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e <code>Bayer<\/code>, \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0430\u0432\u0442\u043e\u0440\u0430). \u0412  PostgreSQL \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0434 \u0441\u043e\u0431\u043e\u0439 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:  <\/p>\n<ul>\n<li>\n<p> \u041a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b  <\/p>\n<\/li>\n<li>\n<p> \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0443\u0437\u043b\u044b  <\/p>\n<\/li>\n<li>\n<p> \u041b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b   <\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u0443 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u043a\u0440\u0443\u0442\u044b\u0435 \u043f\u043b\u044e\u0448\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041d\u043e \u044d\u0442\u043e \u044f \u0434\u0443\u043c\u0430\u044e \u043d\u0443\u0436\u043d\u043e \u043b\u044e\u0434\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0411\u0414, \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0431\u0430\u0437\u0438\u0441\u0442\u0430\u043c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0449\u0438\u043c \u044d\u0442\u0443 \u0438\u043d\u0444\u0440\u0443 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. <\/p>\n<p>\u041d\u0430\u0441 \u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b \u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u043d\u0438\u0445.  <\/p>\n<p>\u041b\u0438\u0441\u0442\u043e\u0432\u043e\u0439 \u0443\u0437\u0435\u043b (leaf node) \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0436\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0412 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u043c \u0443\u0437\u043b\u0435 &#8212; \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Page &#8212; \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 TID (\u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e 8 KB). \u0421\u0430\u043c PostgreSQL \u0445\u0440\u0430\u043d\u0438\u0442 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u043d\u043e\u0434\u044b \u0432 \u0432\u0438\u0434\u0435 \u0434\u0432\u0443\u0445\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 (\u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0436\u043d\u043e \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435).  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0430 1 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430   <\/p>\n<pre><code class=\"sql\">-- \u0422\u0430\u0431\u043b\u0438\u0446\u0430 CREATE TABLE IF NOT EXISTS public.bank_transactions (     id integer NOT NULL DEFAULT nextval('bank_transactions_id_seq'::regclass),     sender_id integer NOT NULL,     receiver_id integer NOT NULL,     amount numeric(12,2) NOT NULL,     transaction_date date NOT NULL,     payment_type text COLLATE pg_catalog.\"default\" NOT NULL DEFAULT '\u0421\u0411\u041f'::text )<\/code><\/pre>\n<p> \u041d\u0430\u0433\u0435\u043d\u0435\u0440\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0445  <\/p>\n<pre><code class=\"sql\">INSERT INTO bank_transactions (sender_id, receiver_id, amount, transaction_date, payment_type) SELECT     (random() * 100000)::int,                          -- sender_id     (random() * 100000)::int,                          -- receiver_id     ROUND((random() * 50000)::numeric, 2),             -- amount     DATE '2023-01-01' + (random() * 365)::int,         -- transaction_date     (ARRAY['\u0421\u0411\u041f', 'SWIFT', '\u0412\u041d\u0423\u0422\u0420\u0415\u041d\u041d\u0418\u0419', '\u041c\u0435\u0436\u0431\u0430\u043d\u043a'])[floor(random() * 4)::int + 1]  -- payment_type FROM generate_series(1, 1000000);  <\/code><\/pre>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 sender_id = 444<\/p>\n<pre><code class=\"sql\">-- \u0417\u0430\u043f\u0440\u043e\u0441 EXPLAIN (ANALYZE, BUFFERS) SELECT *  FROM bank_transactions WHERE bank_transactions.sender_id = 444  -- \u041f\u043b\u0430\u043d Gather  (cost=1000.00..15098.43 rows=11 width=36) (actual time=0.203..47.653 rows=6 loops=1)   Workers Planned: 2   Workers Launched: 2   Buffers: shared hit=7749 read=1140   -&gt;  Parallel Seq Scan on bank_transactions  (cost=0.00..14097.33 rows=5 width=36) (actual time=0.692..20.904 rows=2 loops=3)         Filter: (sender_id = 444)         Rows Removed by Filter: 333331         Buffers: shared hit=7749 read=1140 Planning:   Buffers: shared hit=5 Planning Time: 0.433 ms Execution Time: 47.677 ms<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e SQL \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0448\u0451\u043b\u0441\u044f Seq Scan \u043f\u043e \u0432\u0441\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043b \u043a\u0443\u0447\u0443 \u0441\u0442\u0440\u043e\u043a (Rows Removed by Filter), \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0434\u0430\u043b \u043d\u0430\u043c 6 \u0441\u0442\u0440\u043e\u043a. \u0422.\u0435. \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u0443, \u0435\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c. <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e <code>sender_id<\/code> \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u043d.  <\/p>\n<pre><code class=\"sql\">-- \u0418\u043d\u0434\u0435\u043a\u0441 CREATE INDEX idx_sender_id ON bank_transactions (sender_id);  -- \u041f\u043b\u0430\u043d Bitmap Heap Scan on bank_transactions  (cost=4.51..47.49 rows=11 width=36) (actual time=0.036..0.043 rows=6 loops=1)   Recheck Cond: (sender_id = 444)   Heap Blocks: exact=6   Buffers: shared hit=6 read=3   -&gt;  Bitmap Index Scan on idx_sender_id  (cost=0.00..4.51 rows=11 width=0) (actual time=0.032..0.032 rows=6 loops=1)         Index Cond: (sender_id = 444)         Buffers: shared read=3 Planning:   Buffers: shared hit=15 read=1 Planning Time: 0.725 ms Execution Time: 0.061 ms<\/code><\/pre>\n<p>Bitmap Index Scan &#8212; \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0433\u0434\u0435 sender_id = 5203, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a TID (\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435). <br \/>Bitmap Heap Scan \u2014 \u041f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 TID \u0438\u0434\u0451\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 (heap) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c  <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/989\/9b1\/68c\/9899b168c67ebd0693a8d4c8d31473c4.png\" alt=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Bitmap Index Scan \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \" title=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Bitmap Index Scan \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \" width=\"906\" height=\"387\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/989\/9b1\/68c\/9899b168c67ebd0693a8d4c8d31473c4.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/989\/9b1\/68c\/9899b168c67ebd0693a8d4c8d31473c4.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Bitmap Index Scan \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 <\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u043e\u043d\u044f\u043b\u0438 \u0447\u0442\u043e \u0438 \u043a\u0430\u043a \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 1 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439. <br \/>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0439\u043c\u0451\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.  <\/p>\n<p>\u0412 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445 \u2014 Page \u0445\u0440\u0430\u043d\u0438\u0442 \u043a\u043b\u044e\u0447 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0443\u0436\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0435\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435.  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430, \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u0439 \u0437\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0434\u0430\u0442\u0443. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0431\u0435\u0437 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (\u0438 \u0441\u0442\u0430\u0440\u044b\u0439 \u0443\u0434\u0430\u043b\u0438\u043c).  <\/p>\n<pre><code class=\"sql\">EXPLAIN (ANALYZE, BUFFERS) SELECT *  FROM bank_transactions WHERE bank_transactions.sender_id = 444 AND bank_transactions.transaction_date = '2023-09-24'   --\u041f\u043b\u0430\u043d Gather  (cost=1000.00..16139.10 rows=1 width=36) (actual time=0.203..54.237 rows=1 loops=1)   Workers Planned: 2   Workers Launched: 2   Buffers: shared hit=7877 read=1012   -&gt;  Parallel Seq Scan on bank_transactions  (cost=0.00..15139.00 rows=1 width=36) (actual time=9.925..26.461 rows=0 loops=3)         Filter: ((sender_id = 444) AND (transaction_date = '2023-09-24'::date))         Rows Removed by Filter: 333333         Buffers: shared hit=7877 read=1012 Planning:   Buffers: shared hit=5 dirtied=1 Planning Time: 0.443 ms Execution Time: 54.256 ms<\/code><\/pre>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u0434\u0440\u044f\u0434, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u0443\u044e.<br \/>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441 (\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438)<\/p>\n<pre><code class=\"sql\">-- \u0418\u043d\u0434\u0435\u043a\u0441 CREATE INDEX idx_sender_date ON bank_transactions(sender_id, transaction_date);  -- \u041f\u043b\u0430\u043d Index Scan using idx_sender_date on bank_transactions  (cost=0.42..8.45 rows=1 width=36) (actual time=0.046..0.046 rows=1 loops=1)   Index Cond: ((sender_id = 444) AND (transaction_date = '2023-09-24'::date))   Buffers: shared hit=1 read=3 Planning:   Buffers: shared hit=18 read=1 Planning Time: 1.122 ms Execution Time: 0.062 ms<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043c\u044b \u043f\u0440\u043e\u0448\u043b\u0438\u0441\u044c Index Scan \u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0448\u043b\u0438 \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e <br \/>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0431\u0443\u0434\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442\u0441\u044f <code>sender_id<\/code>, \u0437\u0430\u0442\u0435\u043c <code>transaction_date<\/code>.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f02\/c30\/e7a\/f02c30e7a1a80bd36e9f6a52dbcb833d.png\" alt=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Bitmap Index Scan \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \" title=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Bitmap Index Scan \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \" width=\"906\" height=\"536\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/f02\/c30\/e7a\/f02c30e7a1a80bd36e9f6a52dbcb833d.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f02\/c30\/e7a\/f02c30e7a1a80bd36e9f6a52dbcb833d.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Bitmap Index Scan \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 <\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0434\u0430\u0442\u0443 \u043f\u0435\u0440\u0432\u043e\u0439, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u044b \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b \u043f\u043e \u0434\u0430\u0442\u0430\u043c \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043f\u043e \u043d\u0438\u043c<\/p>\n<\/div>\n<\/details>\n<hr\/>\n<h2>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c &#8212; ESR \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/h2>\n<p>\u041d\u0435\u043b\u044c\u0437\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447, \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c \u2014 \u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044f\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0434\u0451\u0442 \u0432\u044b\u0431\u043e\u0440 \u0442\u043e\u0433\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0432\u0435\u0434\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0432\u043e\u0437\u0434\u0443\u0448\u043d\u044b\u0439 \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c, \u0442\u0430\u043a \u0438 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0425\u043e\u0447\u0443 \u0441\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0434\u0435\u043b\u043e \u0441\u0443\u043f\u0435\u0440 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0435, \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u0431\u0430\u0437\u044b, \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0439. \u041d\u043e \u043f\u043e \u0430\u043d\u0433\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0443 \u0433\u0443\u043b\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e (\u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0432\u0441\u043a\u043e\u043b\u044c\u0437\u044c \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435) ESR (Equality, Sort, Range).  <\/p>\n<p>ESR \u2014 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0430\u0445 \u0434\u043b\u044f B-tree \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e\u043c, \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430, \u0437\u0430\u0442\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b. <\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e ESR?<\/h2>\n<blockquote>\n<p><strong>ESR = Equality \u2192 Sort \u2192 Range<\/strong><\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<ul>\n<li>\n<p><strong>E \u2014 Equality<\/strong>: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0442\u043e\u0438\u0442 <code>=<\/code><\/p>\n<\/li>\n<li>\n<p><strong>S \u2014 Sort<\/strong>: \u0437\u0430\u0442\u0435\u043c \u0442\u0435, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u0434\u0451\u0442 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 (<code>ORDER BY<\/code>)<\/p>\n<\/li>\n<li>\n<p><strong>R \u2014 Range<\/strong>: \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u2014 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0441 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c\u0438 (<code>&gt;<\/code>, <code>&lt;<\/code>, <code>BETWEEN<\/code>)<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e 1 \u0430\u0431\u0437\u0430\u0446 <\/p>\n<blockquote>\n<p>A multicolumn B-tree index can be used with query conditions that involve any subset of the index&#8217;s columns, but the index is most efficient when there are constraints on the leading (leftmost) columns. The exact rule is that equality constraints on leading columns, plus any inequality constraints on the first column that does not have an equality constraint, will be used to limit the portion of the index that is scanned. Constraints on columns to the right of these columns are checked in the index, so they save visits to the table proper, but they do not reduce the portion of the index that has to be scanned. For example, given an index on (a, b, c) and a query condition WHERE a = 5 AND b &gt;= 42 AND c &lt; 77, the index would have to be scanned from the first entry with a = 5 and b = 42 up through the last entry with a = 5. Index entries with c &gt;= 77 would be skipped, but they&#8217;d still have to be scanned through. This index could in principle be used for queries that have constraints on b and\/or c with no constraint on a \u2014 but the entire index would have to be scanned, so in most cases the planner would prefer a sequential table scan over using the index.<\/p>\n<\/blockquote>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c <\/p>\n<p>\u0418\u0437 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0435 \u0437\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0434\u0430\u0442\u0443 , \u0430 \u0437\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u0438 \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439 (\u0412\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u043e\u0434\u043e\u0432\u0441\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043e\u0442\u0447\u0451\u0442\u043e\u0432 \u0431\u0430\u043d\u043a\u0430).<\/p>\n<p>\u041f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435 100 000, \u0430 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 (\u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f \u043f\u0440\u043e\u0434\u043e\u0432\u0441\u043a\u0430\u044f \u0431\u0434 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u044f\u043c\u0438 \u043f\u043e \u0431\u0430\u043d\u043a\u0443). \u041d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0438 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e sender_id \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.   <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0451 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"sql\">INSERT INTO bank_transactions (sender_id, receiver_id, amount, transaction_date, payment_type) SELECT     (random() * 1_000_000)::int,                  -- sender_id     (random() * 1_000_000)::int,     ROUND((random() * 10000)::numeric, 2),     DATE '2020-01-01' + (random() * 2000)::int,     (ARRAY['\u0421\u0411\u041f', 'SWIFT', '\u0412\u041d\u0423\u0422\u0420\u0415\u041d\u041d\u0418\u0419', '\u041c\u0435\u0436\u0431\u0430\u043d\u043a'])[floor(random() * 4)::int + 1] FROM generate_series(1, 10_000_000); <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c 10 000 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 sender_id.<br \/>\u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443 \u2014 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b PostgreSQL \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439. \u042f \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u044e \u043f\u0440\u043e\u0434\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u2014 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0435\u0451 \u043e\u0431\u044a\u0451\u043c \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<br \/>\u0414\u0430, \u043f\u0440\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0451\u043c\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043b\u0430\u043d\u044b \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432  \u2014 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u0443\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u0432\u0441\u0451 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043f\u043e\u0434\u043a\u0440\u0443\u0442\u0438\u0442\u044c, \u043d\u0430\u0439\u0442\u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u043b\u0430\u043d \u0438 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>\u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0434\u0435 \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a \u0436\u0435. \u0422\u0430\u043c \u2014 \u0436\u0435\u0441\u0442\u043a\u0430\u044f \u0431\u043e\u0440\u044c\u0431\u0430 \u0437\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043a\u0435\u0448\u0438 \u043d\u0435 \u0431\u0435\u0437\u0440\u0430\u0437\u043c\u0435\u0440\u043d\u044b\u0435, \u0438 \u0443 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0448\u0430\u043d\u0441 &#171;\u0441\u043f\u0430\u0441\u0442\u0438&#187; \u043a\u043e\u0441\u044f\u043a\u0438 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0427\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0442\u0435\u0441\u0442\u0435 \u0441 10 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u2014 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0443\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0434 \u0441 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c\u0438. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443.<\/p>\n<pre><code class=\"sql\">INSERT INTO bank_transactions (sender_id, receiver_id, amount, transaction_date, payment_type) SELECT     sender_id,     (random() * 1000000)::int,     ROUND((random() * 10000)::numeric, 2),     DATE '2020-01-01' + (random() * 1860)::int,     (ARRAY['\u0421\u0411\u041f', 'SWIFT', '\u041c\u0435\u0436\u0431\u0430\u043d\u043a', '\u0412\u041d\u0423\u0422\u0420\u0415\u041d\u041d\u0418\u0419'])[floor(random() * 4)::int + 1] FROM generate_series(1, 10000) AS sender_id,      generate_series(1, 1000);  -- \u0417\u0430\u043f\u0440\u043e\u0441 EXPLAIN (ANALYZE, BUFFERS) SELECT *  FROM bank_transactions WHERE bank_transactions.sender_id = 444 AND bank_transactions.transaction_date &lt; '2025-05-18' AND bank_transactions.transaction_date &gt; '2020-04-18' AND bank_transactions.payment_type = '\u0421\u0411\u041f'  -- \u041f\u043b\u0430\u043d Seq Scan on bank_transactions  (cost=0.00..871550.86 rows=3541467 width=35) (actual time=5416.344..6795.770 rows=222 loops=1)   Filter: ((transaction_date &lt; '2025-05-18'::date) AND (transaction_date &gt; '2020-04-18'::date) AND (sender_id = 444) AND (payment_type = '\u0421\u0411\u041f'::text))   Rows Removed by Filter: 20999762   Buffers: shared hit=258 read=252001 Planning:   Buffers: shared hit=3 read=2 dirtied=1 Planning Time: 1.006 ms Execution Time: 6795.867 ms<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e sender_id \u2014 \u0441\u0442\u0430\u043b\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a (21 \u043c\u043b\u043d) \u0438 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u0432\u044b\u0447\u043b\u0435\u043d\u0438\u0442\u044c \u043f\u043e sender_id, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0432\u0441\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0447\u0430\u0441\u0442\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c  &#8212; \u043f\u043e\u0439\u0434\u0451\u043c \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044f\u0441\u044c \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f.<\/p>\n<ol>\n<li>\n<p>sender_id \u2014 \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0443\u0447\u0443 \u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439 \u0437\u0430 \u0434\u0430\u0442\u0443<\/p>\n<\/li>\n<li>\n<p>transaction_date \u2014 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u043c\u043e\u0436\u0435\u043c \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0434\u0430\u0442\u0430\u043c<\/p>\n<\/li>\n<li>\n<p>payment_type \u2014 \u0441\u0430\u043c\u043e\u0435 \u043d\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u043e\u043b\u0435<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"sql\">-- \u0418\u043d\u0434\u0435\u043a\u0441 CREATE INDEX idx_sender_date_type ON bank_transactions (sender_id, transaction_date, payment_type);  -- \u041f\u043b\u0430\u043d Index Scan using idx_sender_date_type on bank_transactions  (cost=0.56..254.61 rows=83 width=35) (actual time=0.034..0.325 rows=222 loops=1)   Index Cond: ((sender_id = 444) AND (transaction_date &lt; '2025-05-18'::date) AND (transaction_date &gt; '2020-04-18'::date) AND (payment_type = '\u0421\u0411\u041f'::text))   Buffers: shared hit=230 Planning Time: 0.133 ms Execution Time: 0.354 ms<\/code><\/pre>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u2014 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e. \u041d\u043e \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f: \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c?<br \/>\u0422\u0443\u0442 \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043b\u0438 \u043d\u0430\u043c \u0442\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437\u043d\u0443\u0442\u0440\u0438? <br \/>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e ESR (\u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u2014 \u043f\u043e \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438)<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0438\u043d\u0434\u0435\u043a\u0441 \u0431\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f idx_sender_date_type, \u043f\u0443\u0441\u0442\u044c PostgreSQL \u0441\u0430\u043c \u0440\u0435\u0448\u0438\u0442 \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0431\u0440\u0430\u0442\u044c<\/p>\n<pre><code class=\"sql\">-- \u0418\u043d\u0434\u0435\u043a\u0441 CREATE INDEX idx_sender_type_date ON bank_transactions (sender_id, payment_type, transaction_date);  -- \u041f\u043b\u0430\u043d Index Scan using idx_sender_type_date on bank_transactions  (cost=0.56..246.88 rows=83 width=35) (actual time=0.037..0.184 rows=222 loops=1)   Index Cond: ((sender_id = 444) AND (payment_type = '\u0421\u0411\u041f'::text) AND (transaction_date &lt; '2025-05-18'::date) AND (transaction_date &gt; '2020-04-18'::date))   Buffers: shared hit=226 Planning Time: 0.108 ms Execution Time: 0.204 ms<\/code><\/pre>\n<p>\u0414\u0430\u0436\u0435 \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0435\u0442\u043e\u043c \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <strong>\u043c\u0435\u043d\u044c\u0448\u0435 \u0443\u0437\u043b\u043e\u0432 B-tree<\/strong> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 <strong>\u0431\u044b\u0441\u0442\u0440\u0435\u0435<\/strong>, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0443 ESR<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e.<br \/>\u041a\u043e\u0433\u0434\u0430 PostgreSQL \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443, \u043e\u043d \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0443\u0436\u043d\u044b\u0435 \u0438 \u0442\u0443\u0442 \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 Rows Removed by Filter, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0431\u0435\u0440\u0451\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0438 \u043e\u0442\u0441\u0435\u043a\u0430\u0435\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435.<\/p>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b53\/d53\/c5a\/b53d53c5aa33ac839601db3bea894911.png\" alt=\"\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435\" title=\"\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435\" width=\"714\" height=\"346\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b53\/d53\/c5a\/b53d53c5aa33ac839601db3bea894911.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b53\/d53\/c5a\/b53d53c5aa33ac839601db3bea894911.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435<\/figcaption><\/div>\n<\/figure>\n<hr\/>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u044b\u0431\u043e\u0440 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u043c B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0432\u043a\u0443\u0441\u043e\u0432\u0449\u0438\u043d\u0430, \u0430 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u043e\u0435 \u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c. <br \/>\u041f\u0440\u0430\u0432\u0438\u043b\u043e <strong>ESR (Equality, Sort, Range) <\/strong>\u2014 \u044d\u0442\u043e \u043d\u0435 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430, \u0430 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0451\u043d\u043d\u044b\u0439 \u043f\u043b\u0430\u043d\u0430\u043c\u0438, \u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438, \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0431\u043e\u0440\u043e\u043c PostgreSQL \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 (\u0434\u0430\u0439 \u0431\u043e\u0433 \u0435\u043c\u0443 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f).<br \/>\u041f\u0440\u043e\u0434\u0443\u043c\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u2014 \u0432\u0430\u0436\u043d\u0435\u0439\u0448\u0438\u0439 \u0444\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 PostgreSQL. \u041f\u0440\u0430\u0432\u0438\u043b\u043e ESR \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432\u044b\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u041f\u0440\u0438 \u0440\u043e\u0441\u0442\u0435 \u043e\u0431\u044a\u0451\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u0438 \u043c\u0438\u043d\u0443\u0442\u043d\u044b\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435\u043c.<br \/>\u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0430 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u0445 (\u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0438 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c)<br \/>\u041d\u0443 \u0438 <code>EXPLAIN (ANALYZE, BUFFERS)<\/code> \u0442\u0432\u043e\u0439 \u043b\u0443\u0447\u0448\u0438\u0439 \u0434\u0440\u0443\u0433, \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0431\u0440\u0430\u0442\u044c \u043c\u043e\u0438 \u0441\u043b\u043e\u0432\u0430 \u043d\u0430 \u0432\u0435\u0440\u0443<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u042d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u043c \u0438 \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u044f\u043c <\/p>\n<\/div>\n<\/details>\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\/911688\/\"> https:\/\/habr.com\/ru\/articles\/911688\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 B-tree \u0438\u043d\u0434\u0435\u043a\u0441, \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e &#171;\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441&#187;, \u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u2014 \u0438\u043d\u0430\u0447\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c\u0441\u044f, \u043d\u043e \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e? \u0411\u0440\u0443\u0442\u0444\u043e\u0440\u0441\u043e\u043c? \u041f\u043e \u0438\u043d\u0442\u0443\u0438\u0446\u0438\u0438? \u041f\u043e \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438? <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432 PostgreSQL, \u043d\u0430 \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a. \u0422\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e ESR, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0432\u044b\u0431\u043e\u0440 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0441\u0442\u0435\u043d\u0434\u0430\u0445.<\/p>\n<figure class=\"full-width\">\n<div><figcaption><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%AD%D0%B9%D0%BB%D0%B5%D1%80,_%D0%9B%D0%B5%D0%BE%D0%BD%D0%B0%D1%80%D0%B4#\" rel=\"noopener noreferrer nofollow\">\u041b\u0435\u043e\u043d\u0430\u0440\u0434 \u042d\u0439\u043b\u0435\u0440<\/a> &#8212; \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0442\u0435\u043e\u0440\u0438\u0438 \u0433\u0440\u0430\u0444\u043e\u0432 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%B4%D0%B0%D1%87%D0%B0_%D0%BE_%D1%81%D0%B5%D0%BC%D0%B8_%D0%BA%D1%91%D0%BD%D0%B8%D0%B3%D1%81%D0%B1%D0%B5%D1%80%D0%B3%D1%81%D0%BA%D0%B8%D1%85_%D0%BC%D0%BE%D1%81%D1%82%D0%B0%D1%85\" rel=\"noopener noreferrer nofollow\">\u043a\u0451\u043d\u0438\u0433\u0441\u0431\u0435\u0440\u0433\u0441\u043a\u0438\u0445 \u043c\u043e\u0441\u0442\u0430\u0445<\/a><\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0434\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043e\u0442\u0441\u044b\u043b\u043a\u0443 \u043a \u0442\u0435\u043c\u0435 \u2014 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u042d\u0439\u043b\u0435\u0440\u0430 \u043a\u0430\u043a \u043f\u0435\u0440\u0432\u043e\u043f\u0440\u043e\u0445\u043e\u0434\u0446\u0430 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. <\/p>\n<\/div>\n<\/details>\n<p>\u042f \u2014 \u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0414\u0435\u043d\u0438\u0441\u0435\u043d\u043a\u043e, Sofware Developer. \u0425\u043e\u0447\u0443 \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0430\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.   <\/p>\n<hr\/>\n<h2>\u0412\u0432\u043e\u0434\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c &#8212; \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0438\u0441\u043a \u0432 B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0435<\/h2>\n<p>\u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0439\u043c\u0451\u043c, \u0447\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 B-tree \u0432 PostgreSQL. <\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/postgres\/postgres\/tree\/master\/src\/backend\/access\/nbtree\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434<\/a> \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b PostgreSQL, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u044f \u0445\u043e\u0447\u0443 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u0435, \u0430 \u043d\u0435 \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0434\u0435\u0431\u0440\u0438.  <\/p>\n<\/div>\n<\/details>\n<p>B-tree \u0438\u043b\u0438 \u0436\u0435 \u043c\u043d\u043e\u0433\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e (\u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 B \u0432 B-tree \u2014 \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043d\u0438\u043a\u0442\u043e: \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u0430\u043a <code>balanced<\/code>, <code>broad<\/code> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e <code>Bayer<\/code>, \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0430\u0432\u0442\u043e\u0440\u0430). \u0412  PostgreSQL \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0434 \u0441\u043e\u0431\u043e\u0439 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:  <\/p>\n<ul>\n<li>\n<p> \u041a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b  <\/p>\n<\/li>\n<li>\n<p> \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0443\u0437\u043b\u044b  <\/p>\n<\/li>\n<li>\n<p> \u041b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b   <\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u0443 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u043a\u0440\u0443\u0442\u044b\u0435 \u043f\u043b\u044e\u0448\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041d\u043e \u044d\u0442\u043e \u044f \u0434\u0443\u043c\u0430\u044e \u043d\u0443\u0436\u043d\u043e \u043b\u044e\u0434\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0411\u0414, \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0431\u0430\u0437\u0438\u0441\u0442\u0430\u043c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0449\u0438\u043c \u044d\u0442\u0443 \u0438\u043d\u0444\u0440\u0443 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. <\/p>\n<p>\u041d\u0430\u0441 \u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b \u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u043d\u0438\u0445.  <\/p>\n<p>\u041b\u0438\u0441\u0442\u043e\u0432\u043e\u0439 \u0443\u0437\u0435\u043b (leaf node) \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0436\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0412 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u043c \u0443\u0437\u043b\u0435 &#8212; \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Page &#8212; \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 TID (\u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e 8 KB). \u0421\u0430\u043c PostgreSQL \u0445\u0440\u0430\u043d\u0438\u0442 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u043d\u043e\u0434\u044b \u0432 \u0432\u0438\u0434\u0435 \u0434\u0432\u0443\u0445\u0441\u0432\u044f\u0437\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 (\u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0436\u043d\u043e \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435).  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0430 1 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430   <\/p>\n<pre><code class=\"sql\">-- \u0422\u0430\u0431\u043b\u0438\u0446\u0430 CREATE TABLE IF NOT EXISTS public.bank_transactions (     id integer NOT NULL DEFAULT nextval('bank_transactions_id_seq'::regclass),     sender_id integer NOT NULL,     receiver_id integer NOT NULL,     amount numeric(12,2) NOT NULL,     transaction_date date NOT NULL,     payment_type text COLLATE pg_catalog.\"default\" NOT NULL DEFAULT '\u0421\u0411\u041f'::text )<\/code><\/pre>\n<p> \u041d\u0430\u0433\u0435\u043d\u0435\u0440\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0445  <\/p>\n<pre><code class=\"sql\">INSERT INTO bank_transactions (sender_id, receiver_id, amount, transaction_date, payment_type) SELECT     (random() * 100000)::int,                          -- sender_id     (random() * 100000)::int,                          -- receiver_id     ROUND((random() * 50000)::numeric, 2),             -- amount     DATE '2023-01-01' + (random() * 365)::int,         -- transaction_date     (ARRAY['\u0421\u0411\u041f', 'SWIFT', '\u0412\u041d\u0423\u0422\u0420\u0415\u041d\u041d\u0418\u0419', '\u041c\u0435\u0436\u0431\u0430\u043d\u043a'])[floor(random() * 4)::int + 1]  -- payment_type FROM generate_series(1, 1000000);  <\/code><\/pre>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 sender_id = 444<\/p>\n<pre><code class=\"sql\">-- \u0417\u0430\u043f\u0440\u043e\u0441 EXPLAIN (ANALYZE, BUFFERS) SELECT *  FROM bank_transactions WHERE bank_transactions.sender_id = 444  -- \u041f\u043b\u0430\u043d Gather  (cost=1000.00..15098.43 rows=11 width=36) (actual time=0.203..47.653 rows=6 loops=1)   Workers Planned: 2   Workers Launched: 2   Buffers: shared hit=7749 read=1140   -&gt;  Parallel Seq Scan on bank_transactions  (cost=0.00..14097.33 rows=5 width=36) (actual time=0.692..20.904 rows=2 loops=3)         Filter: (sender_id = 444)         Rows Removed by Filter: 333331         Buffers: shared hit=7749 read=1140 Planning:   Buffers: shared hit=5 Planning Time: 0.433 ms Execution Time: 47.677 ms<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e SQL \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0448\u0451\u043b\u0441\u044f Seq Scan \u043f\u043e \u0432\u0441\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043b \u043a\u0443\u0447\u0443 \u0441\u0442\u0440\u043e\u043a (Rows Removed by Filter), \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0434\u0430\u043b \u043d\u0430\u043c 6 \u0441\u0442\u0440\u043e\u043a. \u0422.\u0435. \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u0443, \u0435\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c. <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e <code>sender_id<\/code> \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u043d.  <\/p>\n<pre><code class=\"sql\">-- \u0418\u043d\u0434\u0435\u043a\u0441 CREATE INDEX idx_sender_id ON bank_transactions (sender_id);  -- \u041f\u043b\u0430\u043d Bitmap Heap Scan on bank_transactions  (cost=4.51..47.49 rows=11 width=36) (actual time=0.036..0.043 rows=6 loops=1)   Recheck Cond: (sender_id = 444)   Heap Blocks: exact=6   Buffers: shared hit=6 read=3   -&gt;  Bitmap Index Scan on idx_sender_id  (cost=0.00..4.51 rows=11 width=0) (actual time=0.032..0.032 rows=6 loops=1)         Index Cond: (sender_id = 444)         Buffers: shared read=3 Planning:   Buffers: shared hit=15 read=1 Planning Time: 0.725 ms Execution Time: 0.061 ms<\/code><\/pre>\n<p>Bitmap Index Scan &#8212; \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0433\u0434\u0435 sender_id = 5203, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a TID (\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435). <br \/>Bitmap Heap Scan \u2014 \u041f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 TID \u0438\u0434\u0451\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 (heap) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c  <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Bitmap Index Scan \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 <\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u043e\u043d\u044f\u043b\u0438 \u0447\u0442\u043e \u0438 \u043a\u0430\u043a \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 1 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439. <br \/>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0439\u043c\u0451\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.  <\/p>\n<p>\u0412 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445 \u2014 Page \u0445\u0440\u0430\u043d\u0438\u0442 \u043a\u043b\u044e\u0447 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0443\u0436\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0435\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435.  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430, \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u0439 \u0437\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0434\u0430\u0442\u0443. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0431\u0435\u0437 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (\u0438 \u0441\u0442\u0430\u0440\u044b\u0439 \u0443\u0434\u0430\u043b\u0438\u043c).  <\/p>\n<pre><code class=\"sql\">EXPLAIN (ANALYZE, BUFFERS) SELECT *  FROM bank_transactions WHERE bank_transactions.sender_id = 444 AND bank_transactions.transaction_date = '2023-09-24'   --\u041f\u043b\u0430\u043d Gather  (cost=1000.00..16139.10 rows=1 width=36) (actual time=0.203..54.237 rows=1 loops=1)   Workers Planned: 2   Workers Launched: 2   Buffers: shared hit=7877 read=1012   -&gt;  Parallel Seq Scan on bank_transactions  (cost=0.00..15139.00 rows=1 width=36) (actual time=9.925..26.461 rows=0 loops=3)         Filter: ((sender_id = 444) AND (transaction_date = '2023-09-24'::date))         Rows Removed by Filter: 333333         Buffers: shared hit=7877 read=1012 Planning:   Buffers: shared hit=5 dirtied=1 Planning Time: 0.443 ms Execution Time: 54.256 ms<\/code><\/pre>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u0434\u0440\u044f\u0434, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u0443\u044e.<br \/>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441 (\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438)<\/p>\n<pre><code class=\"sql\">-- \u0418\u043d\u0434\u0435\u043a\u0441 CREATE INDEX idx_sender_date ON bank_transactions(sender_id, transaction_date);  -- \u041f\u043b\u0430\u043d Index Scan using idx_sender_date on bank_transactions  (cost=0.42..8.45 rows=1 width=36) (actual time=0.046..0.046 rows=1 loops=1)   Index Cond: ((sender_id = 444) AND (transaction_date = '2023-09-24'::date))   Buffers: shared hit=1 read=3 Planning:   Buffers: shared hit=18 read=1 Planning Time: 1.122 ms Execution Time: 0.062 ms<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043c\u044b \u043f\u0440\u043e\u0448\u043b\u0438\u0441\u044c Index Scan \u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0448\u043b\u0438 \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e <br \/>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0431\u0443\u0434\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442\u0441\u044f <code>sender_id<\/code>, \u0437\u0430\u0442\u0435\u043c <code>transaction_date<\/code>.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Bitmap Index Scan \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 <\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0434\u0430\u0442\u0443 \u043f\u0435\u0440\u0432\u043e\u0439, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u044b \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b \u043f\u043e \u0434\u0430\u0442\u0430\u043c \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043f\u043e \u043d\u0438\u043c<\/p>\n<\/div>\n<\/details>\n<hr\/>\n<h2>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c &#8212; ESR \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/h2>\n<p>\u041d\u0435\u043b\u044c\u0437\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447, \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c \u2014 \u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044f\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0434\u0451\u0442 \u0432\u044b\u0431\u043e\u0440 \u0442\u043e\u0433\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0432\u0435\u0434\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0432\u043e\u0437\u0434\u0443\u0448\u043d\u044b\u0439 \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c, \u0442\u0430\u043a \u0438 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0425\u043e\u0447\u0443 \u0441\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2014 \u0434\u0435\u043b\u043e \u0441\u0443\u043f\u0435\u0440 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0435, \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u0431\u0430\u0437\u044b, \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0439. \u041d\u043e \u043f\u043e \u0430\u043d\u0433\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0443 \u0433\u0443\u043b\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e (\u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b \u0432\u0441\u043a\u043e\u043b\u044c\u0437\u044c \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435) ESR (Equality, Sort, Range).  <\/p>\n<p>ESR \u2014 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0430\u0445 \u0434\u043b\u044f B-tree \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e\u043c, \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430, \u0437\u0430\u0442\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b. <\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e ESR?<\/h2>\n<blockquote>\n<p><strong>ESR = Equality \u2192 Sort \u2192 Range<\/strong><\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<ul>\n<li>\n<p><strong>E \u2014 Equality<\/strong>: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0442\u043e\u0438\u0442 <code>=<\/code><\/p>\n<\/li>\n<li>\n<p><strong>S \u2014 Sort<\/strong>: \u0437\u0430\u0442\u0435\u043c \u0442\u0435, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u0434\u0451\u0442 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 (<code>ORDER BY<\/code>)<\/p>\n<\/li>\n<li>\n<p><strong>R \u2014 Range<\/strong>: \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u2014 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0441 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u043c\u0438 (<code>&gt;<\/code>, <code>&lt;<\/code>, <code>BETWEEN<\/code>)<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e 1 \u0430\u0431\u0437\u0430\u0446 <\/p>\n<blockquote>\n<p>A multicolumn B-tree index can be used with query conditions that involve any subset of the index&#8217;s columns, but the index is most efficient when there are constraints on the leading (leftmost) columns. The exact rule is that equality constraints on leading columns, plus any inequality constraints on the first column that does not have an equality constraint, will be used to limit the portion of the index that is scanned. Constraints on columns to the right of these columns are checked in the index, so they save visits to the table proper, but they do not reduce the portion of the index that has to be scanned. For example, given an index on (a, b, c) and a query condition WHERE a = 5 AND b &gt;= 42 AND c &lt; 77, the index would have to be scanned from the first entry with a = 5 and b = 42 up through the last entry with a = 5. Index entries with c &gt;= 77 would be skipped, but they&#8217;d still have to be scanned through. This index could in principle be used for queries that have constraints on b and\/or c with no constraint on a \u2014 but the entire index would have to be scanned, so in most cases the planner would prefer a sequential table scan over using the index.<\/p>\n<\/blockquote>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c <\/p>\n<p>\u0418\u0437 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0435 \u0437\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0434\u0430\u0442\u0443 , \u0430 \u0437\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u0438 \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439 (\u0412\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u043e\u0434\u043e\u0432\u0441\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043e\u0442\u0447\u0451\u0442\u043e\u0432 \u0431\u0430\u043d\u043a\u0430).<\/p>\n<p>\u041f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435 100 000, \u0430 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 (\u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f \u043f\u0440\u043e\u0434\u043e\u0432\u0441\u043a\u0430\u044f \u0431\u0434 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u044f\u043c\u0438 \u043f\u043e \u0431\u0430\u043d\u043a\u0443). \u041d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0438 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e sender_id \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.   <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0451 \u0434\u0430\u043d\u043d\u044b\u0445<\/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-460483","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/460483","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=460483"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/460483\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=460483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=460483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=460483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}