{"id":298919,"date":"2020-02-19T09:00:30","date_gmt":"2020-02-19T09:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298919"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298919","title":{"rendered":"DBA: \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/488104\/\">\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442, \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 PostgreSQL \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0448\u0432\u0435\u0439\u0446\u0430\u0440\u0441\u043a\u0438\u0439 \u043d\u043e\u0436, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441 \u043b\u044e\u0431\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <i><b>\u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441<\/b><\/i> \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u043b\u0438 <i><b>\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u043a\u0443\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c<\/b><\/i> \u0432 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 (\u043c\u0430\u0433\u0438\u044f-\u043c\u0430\u0433\u0438\u044f!) \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7f\/ay\/qh\/7fayqhfcbpano3cagjluq6cxary.png\"><br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442, \u0438\u043b\u0438 \u043d\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u0438\u043b\u0438 \u043d\u0435 \u0432\u0441\u0435. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043b\u0438\u0448\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u044f\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>  \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u0430\u043a\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043f\u0440\u0438 \u00ab\u0434\u043e\u043b\u0433\u043e\u0438\u0433\u0440\u0430\u044e\u0449\u0435\u0439\u00bb \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0437\u0430\u043a\u0430\u0437\u043d\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043f\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u00ab\u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0440\u0430\u0437\u043e\u0432\u043e, \u043e\u0442\u0434\u0430\u043b, \u0437\u0430\u0431\u044b\u043b\u00bb, \u0430, \u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/sbis.ru\/all_services\">\u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u0434\u043b\u0438\u043d\u043d\u044b\u043c \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c<\/a>.<\/p>\n<p>  \u0414\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0441\u0438\u043b\u0430\u043c\u0438 <a href=\"https:\/\/sbis.ru\/about\">\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u0435\u0441\u0435\u043d\u044b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u043e \u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0418 \u0442\u043e\u0433\u0434\u0430, \u043d\u0435 \u0437\u043d\u0430\u044f \u0432\u0441\u0435\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0435\u0433\u043e \u0411\u0414, \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u00ab\u043d\u0430\u043f\u043e\u0440\u0442\u0430\u0447\u0438\u0442\u044c\u00bb \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438. \u041d\u043e \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 <b>\u043f\u0440\u043e\u0432\u0435\u0440\u043e\u0447\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c<\/b> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<ul>\n<li>\u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b<\/li>\n<li>\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0435 \u00ab\u043a\u043b\u043e\u043d\u044b\u00bb<\/li>\n<li>timestamp \u00ab\u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435\u00bb<\/li>\n<li>\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u044b\u0439 boolean<\/li>\n<li>\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435<\/li>\n<li>NULL-\u043c\u0443\u0441\u043e\u0440<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a><br \/>  \u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u2014 \u043d\u0430\u0439\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c <b>\u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432<\/b>. \u0422\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0441\u0431\u0440\u043e\u0441 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 (<code>pg_stat_reset()<\/code>) \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u0430\u0432\u043d\u043e, \u0438 \u0432\u044b \u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u00ab\u0440\u0435\u0434\u043a\u043e, \u043d\u043e \u043c\u0435\u0442\u043a\u043e\u00bb. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c <code>pg_stat_user_indexes<\/code>:<\/p>\n<pre><code class=\"sql\">SELECT * FROM pg_stat_user_indexes WHERE idx_scan = 0;<\/code><\/pre>\n<p>  \u041d\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u043b \u0432 \u044d\u0442\u0443 \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u044d\u0442\u043e \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<h2>\u0414\u043b\u044f \u0447\u0435\u0433\u043e [\u043d\u0435] \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b<\/h2>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u00ab\u043f\u043b\u043e\u0445\u043e \u0445\u043e\u0434\u044f\u0442 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443\u00bb, \u0437\u0430\u0434\u0443\u043c\u0430\u0435\u043c\u0441\u044f \u043e <a href=\"https:\/\/habr.com\/company\/postgrespro\/blog\/330544\/\">\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e <b>btree<\/b>-\u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/a> \u2014 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\u0433\u043e \u0432 \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430. \u0418\u043d\u0434\u0435\u043a\u0441\u044b \u0438\u0437 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u043c \u0438\u0437 \u043f\u0430\u0440\u044b \u043f\u043e\u043b\u0435\u0439.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u0430\u043a \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u2014 \u044d\u0442\u043e \u00ab\u0441\u043b\u043e\u0435\u043d\u044b\u0439 \u043f\u0438\u0440\u043e\u0433\u00bb, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043b\u043e\u0435 \u2014 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u043f\u043e\u043b\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uc\/nq\/tu\/ucnqtujhwddszfy7aj5gitnqona.png\"><\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0435 <b>A \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e, \u0430 B \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f A<\/b>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445, \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u00ab\u0445\u043e\u0434\u0438\u0442\u044c\u00bb \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443.<\/p>\n<h4><font color=\"#008000\">\u0425\u043e\u0440\u043e\u0448\u043e: \u043f\u0440\u0435\u0444\u0438\u043a\u0441-\u0443\u0441\u043b\u043e\u0432\u0438\u0435<\/font><\/h4>\n<p>  \u0417\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 <code>btree(A, B)<\/code> \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u00ab\u043f\u043e\u0434\u0438\u043d\u0434\u0435\u043a\u0441\u00bb <code>btree(A)<\/code>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u0447\u0435\u043c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 <code>btree(A, B, C)<\/code> \u2014 \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0432 \u0431\u0430\u0437\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u00ab\u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f\u00bb:<\/p>\n<ul>\n<li><code>btree(A, B, C)<\/code><\/li>\n<li><code>btree(A, B)<\/code><\/li>\n<li><code>btree(A)<\/code><\/li>\n<\/ul>\n<p>  \u0410 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u00ab\u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0435\u00bb \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0435\u0444\u0438\u043a\u0441-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u0431\u0430\u0437\u0435 \u2014 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u0412\u0435\u0434\u044c <b>\u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u2014 \u0442\u0435\u043c \u0445\u0443\u0436\u0435<\/b> \u0434\u043b\u044f PostgreSQL, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 Write Amplification \u2014 \u043d\u0430 \u044d\u0442\u043e \u0435\u0449\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/southbridge\/blog\/322624\/\">Uber \u0436\u0430\u043b\u043e\u0432\u0430\u043b\u0441\u044f<\/a> (\u0430 \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/habr.com\/ru\/company\/devconf\/blog\/353682\/\">\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0438\u0445 \u043f\u0440\u0435\u0442\u0435\u043d\u0437\u0438\u0439<\/a>).<\/p>\n<p>  \u0410 \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043c\u0435\u0448\u0430\u0435\u0442 \u0431\u0430\u0437\u0435 \u0436\u0438\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0441\u0442\u043e\u0438\u0442 \u044d\u0442\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl(A integer, B integer, val integer); CREATE INDEX ON tbl(A, B)   WHERE val IS NULL; CREATE INDEX ON tbl(A) -- \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0439 #1   WHERE val IS NULL; CREATE INDEX ON tbl(A, B, val); CREATE INDEX ON tbl(A); -- \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0439 #2<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">WITH sch AS (   SELECT     'public'::text sch -- schema ) , def AS (   SELECT     clr.relname nmt   , cli.relname nmi   , pg_get_indexdef(cli.oid) def   , cli.oid clioid   , clr   , cli   , idx , (     SELECT       array_agg(T::text ORDER BY f.i)     FROM       (         SELECT           clr.oid rel         , i         , idx.indkey[i] ik         FROM           generate_subscripts(idx.indkey, 1) i       ) f     JOIN       pg_attribute T         ON (T.attrelid, T.attnum) = (f.rel, f.ik)   ) fld$   FROM     pg_class clr   JOIN     pg_index idx       ON idx.indrelid = clr.oid AND       idx.indexprs IS NULL   JOIN     pg_class cli       ON cli.oid = idx.indexrelid   JOIN     pg_namespace nsp       ON nsp.oid = cli.relnamespace AND       nsp.nspname = (TABLE sch)   WHERE     NOT idx.indisunique AND     idx.indisready AND     idx.indisvalid   ORDER BY     clr.relname, cli.relname ) , fld AS (   SELECT     *   , ARRAY(       SELECT         (att::pg_attribute).attname       FROM         unnest(fld$) att     ) nmf$   , ARRAY(       SELECT         (           SELECT             typname           FROM             pg_type           WHERE             oid = (att::pg_attribute).atttypid         )       FROM         unnest(fld$) att     ) tpf$   , CASE       WHEN def ~ ' WHERE ' THEN regexp_replace(def, E'.* WHERE ', '')     END wh   FROM     def ) , pre AS (   SELECT     nmt   , wh   , nmf$   , tpf$   , nmi   , def   FROM     fld   ORDER BY     1, 2, 3 ) SELECT DISTINCT   Y.* FROM   pre X JOIN   pre Y     ON Y.nmi &lt;&gt; X.nmi AND     (Y.nmt, Y.wh) IS NOT DISTINCT FROM (X.nmt, X.wh) AND     (       Y.nmf$[1:array_length(X.nmf$, 1)] = X.nmf$ OR       X.nmf$[1:array_length(Y.nmf$, 1)] = Y.nmf$     ) ORDER BY   1, 2, 3; <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0412 \u0438\u0434\u0435\u0430\u043b\u0435, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u2014 \u0432\u043e\u0442 \u043d\u0430\u0448\u0438 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432:<\/p>\n<pre><code class=\"plaintext\">nmt | wh            | nmf$      | tpf$             | nmi             | def --------------------------------------------------------------------------------------- tbl | (val IS NULL) | {a}       | {int4}           | tbl_a_idx       | CREATE INDEX ... tbl | (val IS NULL) | {a,b}     | {int4,int4}      | tbl_a_b_idx     | CREATE INDEX ... tbl |               | {a}       | {int4}           | tbl_a_idx1      | CREATE INDEX ... tbl |               | {a,b,val} | {int4,int4,int4} | tbl_a_b_val_idx | CREATE INDEX ... <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u0441\u0430\u043c\u0438 \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 \u2014 \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b.<\/p>\n<h4><font color=\"#008000\">\u0425\u043e\u0440\u043e\u0448\u043e: \u0432\u0441\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e\u043b\u044f<\/font><\/h4>\n<p>  \u0415\u0441\u043b\u0438 <b>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e, \u0437\u0430\u0434\u0430\u043d\u044b \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438<\/b> (\u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u043f\u043e\u043b\u0435 A) \u2014 \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e\u043b\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439, \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e\u043c, \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c, \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0447\u0435\u0440\u0435\u0437 <code>IN (...)<\/code> \u0438\u043b\u0438 <code>= ANY(...)<\/code>. \u0410 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e \u043d\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xy\/qt\/2t\/xyqt2tnwfc37wsztb96hzsp5ngu.png\"><\/p>\n<ul>\n<li><code>WHERE A = constA AND B <b>[op]<\/b> constB \/ <b>= ANY<\/b>(...) \/ <b>IN<\/b> (...)<\/code><br \/>  <code>op : { =, &gt;, &gt;=, &lt;, &lt;= }<\/code><\/li>\n<li><code>WHERE A = constA AND B <b>BETWEEN<\/b> constB1 AND constB2<\/code><\/li>\n<li><code>WHERE A = constA <b>ORDER BY<\/b> B<\/code><\/li>\n<\/ul>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043f\u0440\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u044d\u0442\u043e:<\/p>\n<ul>\n<li><code>WHERE A <b>[op]<\/b> const \/ <b>= ANY<\/b>(...) \/ <b>IN<\/b> (...)<\/code><br \/>  <code>op : { =, &gt;, &gt;=, &lt;, &lt;= }<\/code><\/li>\n<li><code>WHERE A <b>BETWEEN<\/b> const1 AND const2<\/code><\/li>\n<li><code><b>ORDER BY<\/b> A<\/code><\/li>\n<li><code>WHERE (A, B) <b>[op]<\/b> (constA, constB) \/ <b>= ANY<\/b>(...) \/ <b>IN<\/b> (...)<\/code><br \/>  <code>op : { =, &gt;, &gt;=, &lt;, &lt;= }<\/code><\/li>\n<li><code><b>ORDER BY<\/b> A, B<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<h4><font color=\"#c04000\">\u041f\u043b\u043e\u0445\u043e: \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u00ab\u0441\u043b\u043e\u044f\u00bb<\/font><\/h4>\n<p>  \u041f\u0440\u0438 \u0447\u0430\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u043e\u0439 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u044b\u0439 <b>\u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/b> \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0438\u0437 \u00ab\u0441\u043b\u043e\u0435\u0432\u00bb. \u041f\u043e\u0432\u0435\u0437\u0435\u0442, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u2014 \u0430 \u0435\u0441\u043b\u0438 \u0442\u044b\u0441\u044f\u0447\u0438?..<\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 <i><b>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u043d\u0435\u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e<\/b><\/i>, \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 <i><b>\u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435<\/b><\/i> \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e\u043b\u044f \u0438\u043b\u0438 \u044d\u0442\u043e\u0442 <i><b>\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043d\u0430\u0440\u0443\u0448\u0435\u043d<\/b><\/i> \u043f\u0440\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435.<\/p>\n<ul>\n<li><code>WHERE A <b>&lt;&gt;<\/b> const<\/code><\/li>\n<li><code>WHERE B [op] const \/ = ANY(...) \/ IN (...)<\/code><\/li>\n<li><code>ORDER BY B<\/code><\/li>\n<li><code>ORDER BY B, A<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<h4><font color=\"#c04000\">\u041f\u043b\u043e\u0445\u043e: \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0438\u043b\u0438 \u043d\u0430\u0431\u043e\u0440 \u043d\u0435 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u043b\u0435<\/font><\/h4>\n<p>  \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u2014 \u0435\u0441\u043b\u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u043c \u00ab\u0441\u043b\u043e\u0435\u00bb \u043d\u0430\u0434\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u043b\u0438 \u0438\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d, \u0430 \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043b\u0435\u0436\u0430\u0449\u0438\u043c \u00ab\u0433\u043b\u0443\u0431\u0436\u0435\u00bb \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043f\u043e\u043b\u044f\u043c, \u2014 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u00ab\u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435\u00bb \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<ul>\n<li><code>WHERE A <b>BETWEEN<\/b> constA1 AND constA2 AND B <b>BETWEEN<\/b> constB1 AND constB2<\/code><\/li>\n<li><code>WHERE A <b>= ANY(...)<\/b> AND B = const<\/code><\/li>\n<li><code>WHERE A <b>= ANY(...)<\/b> ORDER BY B<\/code><\/li>\n<li><code>WHERE A <b>= ANY(...)<\/b> AND B = ANY(...)<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<h4><font color=\"#c04000\">\u041f\u043b\u043e\u0445\u043e: \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u043b\u044f<\/font><\/h4>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435\u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0432\u043e \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435 \u2014 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u043e\u0442 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li><code>WHERE <b>A - const1<\/b> [op] const2<\/code><br \/>  \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c: <code>WHERE A [op] <b>const1 + const2<\/b><\/code><\/li>\n<li><code>WHERE <b>A::typeOfConst<\/b> = const<\/code><br \/>  \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c: <code>WHERE A = <b>const::typeOfA<\/b><\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0439<\/h2>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0438\u043d\u0434\u0435\u043a\u0441 <code>(A, B)<\/code>, \u043f\u0440\u0438\u0447\u0435\u043c \u0432\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 <b>\u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0443<\/b>: <code>(A, B) = (constA, constB)<\/code>. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/postgrespro\/blog\/328280\/\">hash-\u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/a>, \u043d\u043e\u2026 \u041f\u043e\u043c\u0438\u043c\u043e \u043d\u0435\u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (wal logging) \u0442\u0430\u043a\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u0432\u0435\u0440\u0441\u0438\u0438 10, \u043e\u043d\u0438 \u0435\u0449\u0435 \u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u043b\u044f\u0445:<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON tbl USING hash(A, B); -- ERROR:  access method &quot;hash&quot; does not support multicolumn indexes<\/code><\/pre>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c, \u0432\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 btree. \u0422\u0430\u043a \u043a\u0430\u043a \u0436\u0435 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043d\u0435\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u2014 <code>(A, B)<\/code> \u0438\u043b\u0438 <code>(B, A)<\/code>? \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043d\u0430\u0434\u043e \u0443\u0447\u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u0430\u043a <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9C%D0%BE%D1%89%D0%BD%D0%BE%D1%81%D1%82%D1%8C_%D0%BC%D0%BD%D0%BE%D0%B6%D0%B5%D1%81%D1%82%D0%B2%D0%B0\">\u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445<\/a> \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043d\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e <code>A = {1,2}, B = {1,2,3,4}<\/code>, \u0438 \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u0441\u0445\u0435\u043c\u0443 \u0434\u0435\u0440\u0435\u0432\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/iu\/bv\/xx\/iubvxx2xilnlkhkihtjnjacaekk.png\"><\/p>\n<p>  \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u0434\u0435\u0440\u0435\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b\u0438, \u2014 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435. \u0418 \u0447\u0435\u043c \u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 \u2014 \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0434\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441, \u0442\u0435\u043c \u0434\u043e\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043d\u0435\u0433\u043e.<\/p>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <code>(A, B)<\/code> \u0438\u043c\u0435\u0435\u0442 10 \u0443\u0437\u043b\u043e\u0432, \u0430 <code>(B, A)<\/code> \u2014 12. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0433\u043e\u0434\u043d\u0435\u0435 \u0441\u0442\u0430\u0432\u0438\u0442\u044c <b>\u00ab\u043f\u0435\u0440\u0432\u044b\u043c\u0438\u00bb \u043f\u043e\u043b\u044f, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/b>.<\/p>\n<h4><font color=\"#c04000\">\u041f\u043b\u043e\u0445\u043e: \u043c\u043d\u043e\u0433\u043e \u0438 \u043d\u0435 \u043a \u043c\u0435\u0441\u0442\u0443 (timestamp \u00ab\u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435\u00bb)<\/font><\/h4>\n<p>  \u0420\u043e\u0432\u043d\u043e \u043f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043f\u043e\u043b\u0435 \u0441 \u0437\u0430\u0432\u0435\u0434\u043e\u043c\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0438\u043f\u0430 <b>timestamp[tz] \u0441\u0442\u043e\u0438\u0442 \u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c<\/b>. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f timestamp-\u043f\u043e\u043b\u044f \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u044e\u0442, \u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438\u043c\u0435\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435.<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl(A integer, B timestamp); CREATE INDEX ON tbl(A, B); CREATE INDEX ON tbl(B, A); -- \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/m_\/-e\/qm\/m_-eqmqod5kyvkako8evgt-a98s.png\"><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0435-\u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 timestamp[tz] \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">WITH sch AS (   SELECT     'public'::text sch -- schema ) , def AS (   SELECT     clr.relname nmt   , cli.relname nmi   , pg_get_indexdef(cli.oid) def   , cli.oid clioid   , clr   , cli   , idx , (     SELECT       array_agg(T::text ORDER BY f.i)     FROM       (         SELECT           clr.oid rel         , i         , idx.indkey[i] ik         FROM           generate_subscripts(idx.indkey, 1) i       ) f     JOIN       pg_attribute T         ON (T.attrelid, T.attnum) = (f.rel, f.ik)   ) fld$ , (     SELECT       array_agg(replace(opcname::text, '_ops', '') ORDER BY f.i)     FROM       (         SELECT           clr.oid rel         , i         , idx.indclass[i] ik         FROM           generate_subscripts(idx.indclass, 1) i       ) f     JOIN       pg_opclass T         ON T.oid = f.ik   ) opc$   FROM     pg_class clr   JOIN     pg_index idx       ON idx.indrelid = clr.oid   JOIN     pg_class cli       ON cli.oid = idx.indexrelid   JOIN     pg_namespace nsp       ON nsp.oid = cli.relnamespace AND       nsp.nspname = (TABLE sch)   WHERE     NOT idx.indisunique AND     idx.indisready AND     idx.indisvalid   ORDER BY     clr.relname, cli.relname ) , fld AS (   SELECT     *   , ARRAY(       SELECT         (att::pg_attribute).attname       FROM         unnest(fld$) att     ) nmf$   , ARRAY(       SELECT         (           SELECT             typname           FROM             pg_type           WHERE             oid = (att::pg_attribute).atttypid         )       FROM         unnest(fld$) att     ) tpf$   FROM     def ) SELECT   nmt , nmi , def , nmf$ , tpf$ , opc$ FROM   fld WHERE   'timestamp' = ANY(tpf$[1:array_length(tpf$, 1) - 1]) OR   'timestamptz' = ANY(tpf$[1:array_length(tpf$, 1) - 1]) OR   'timestamp' = ANY(opc$[1:array_length(opc$, 1) - 1]) OR   'timestamptz' = ANY(opc$[1:array_length(opc$, 1) - 1]) ORDER BY   1, 2; <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0422\u0443\u0442 \u043c\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0438 \u0442\u0438\u043f\u044b \u0441\u0430\u043c\u0438\u0445 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u043b\u0435\u0439, \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u043a \u043d\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u2014 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a\u0430\u044f-\u0442\u043e timestamptz-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0440\u043e\u0434\u0435 date_trunc.<\/p>\n<pre><code class=\"plaintext\">nmt | nmi         | def              | nmf$  | tpf$             | opc$ ---------------------------------------------------------------------------------- tbl | tbl_b_a_idx | CREATE INDEX ... | {b,a} | {timestamp,int4} | {timestamp,int4} <\/code><\/pre>\n<p>  <\/p>\n<h4><font color=\"#c04000\">\u041f\u043b\u043e\u0445\u043e: \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e (boolean)<\/font><\/h4>\n<p>  \u041e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u044d\u0442\u043e\u0439 \u0436\u0435 \u043c\u0435\u0434\u0430\u043b\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <b>boolean-\u043f\u043e\u043b\u0435<\/b>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u043e 3 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f: <code>NULL, FALSE, TRUE<\/code>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0433\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0432 \u0438\u043c \u0442\u0438\u043f \u0443\u0437\u043b\u0430 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0434\u0435\u0440\u0435\u0432\u0430 \u2014 \u043f\u0430\u043f\u043a\u0430 \u044d\u0442\u043e \u0438\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043b\u0438\u0441\u0442 (\u00ab\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0430\u043f\u043a\u0438\u00bb).<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl(   id     serial       PRIMARY KEY , leaf_pid     integer , leaf_type     boolean , public     boolean ); CREATE INDEX ON tbl(leaf_pid, leaf_type); -- \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 CREATE INDEX ON tbl(public, id); -- \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 <\/code><\/pre>\n<p>  \u041d\u043e, \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u044d\u0442\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u0430\u043a, \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0445\u043e\u0434\u044f\u0442 \u0441 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c boolean-\u043f\u043e\u043b\u044f. \u0418 \u0442\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u0441 \u0442\u0430\u043a\u0438\u043c \u043f\u043e\u043b\u0435\u043c \u043d\u0430 \u0435\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e:<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON tbl(id) WHERE public;<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 boolean \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">WITH sch AS (   SELECT     'public'::text sch -- schema ) , def AS (   SELECT     clr.relname nmt   , cli.relname nmi   , pg_get_indexdef(cli.oid) def   , cli.oid clioid   , clr   , cli   , idx , (     SELECT       array_agg(T::text ORDER BY f.i)     FROM       (         SELECT           clr.oid rel         , i         , idx.indkey[i] ik         FROM           generate_subscripts(idx.indkey, 1) i       ) f     JOIN       pg_attribute T         ON (T.attrelid, T.attnum) = (f.rel, f.ik)   ) fld$ , (     SELECT       array_agg(replace(opcname::text, '_ops', '') ORDER BY f.i)     FROM       (         SELECT           clr.oid rel         , i         , idx.indclass[i] ik         FROM           generate_subscripts(idx.indclass, 1) i       ) f     JOIN       pg_opclass T         ON T.oid = f.ik   ) opc$   FROM     pg_class clr   JOIN     pg_index idx       ON idx.indrelid = clr.oid   JOIN     pg_class cli       ON cli.oid = idx.indexrelid   JOIN     pg_namespace nsp       ON nsp.oid = cli.relnamespace AND       nsp.nspname = (TABLE sch)   WHERE     NOT idx.indisunique AND     idx.indisready AND     idx.indisvalid   ORDER BY     clr.relname, cli.relname ) , fld AS (   SELECT     *   , ARRAY(       SELECT         (att::pg_attribute).attname       FROM         unnest(fld$) att     ) nmf$   , ARRAY(       SELECT         (           SELECT             typname           FROM             pg_type           WHERE             oid = (att::pg_attribute).atttypid         )       FROM         unnest(fld$) att     ) tpf$   FROM     def ) SELECT   nmt , nmi , def , nmf$ , tpf$ , opc$ FROM   fld WHERE   (     'bool' = ANY(tpf$) OR     'bool' = ANY(opc$)   ) AND   NOT(     ARRAY(       SELECT         nmf$[i:i+1]::text       FROM         generate_series(1, array_length(nmf$, 1) - 1) i     ) &amp;&amp;     ARRAY[ -- \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u044b-\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0432\u043a\u0443\u0441\u0443       '{leaf_pid,leaf_type}'     ]   ) ORDER BY   1, 2;<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"plaintext\">nmt | nmi               | def              | nmf$        | tpf$        | opc$ ------------------------------------------------------------------------------------ tbl | tbl_public_id_idx | CREATE INDEX ... | {public,id} | {bool,int4} | {bool,int4} <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041c\u0430\u0441\u0441\u0438\u0432\u044b \u0432 btree<\/h2>\n<p>  \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u0438\u0434\u0443\u0442 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u00ab\u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u00bb \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e btree-\u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u042d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a \u043d\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/functions-array\">\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/a>:  <\/p>\n<blockquote><p><b>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u044f<\/b> \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 (<code>&lt;, &gt;, =<\/code> \u0438 \u0442. \u0434.) \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f B-\u0434\u0435\u0440\u0435\u0432\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442 \u0438\u0445 \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044e. \u0412 \u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c (\u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c). \u0415\u0441\u043b\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0434\u0432\u0443\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0445 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044f\u0445.<\/p><\/blockquote>\n<p>\u041d\u043e \u0431\u0435\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c-\u0442\u043e \u0435\u0433\u043e \u0445\u043e\u0442\u044f\u0442 \u0441 <b>\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f<\/b>: <code>&lt;@, @&gt;, &amp;&amp;<\/code>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0442\u0430\u043a \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u2014 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u044b <a href=\"https:\/\/habr.com\/ru\/company\/postgrespro\/blog\/340978\/\">\u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/a>. \u041a\u0430\u043a \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 btree \u0438 \u0434\u043b\u044f <b>\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/b> \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 <code>arr[i]<\/code>.<\/p>\n<p>  \u041d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0438 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl(   id     serial       PRIMARY KEY , pid     integer , list     integer[] ); CREATE INDEX ON tbl(pid); CREATE INDEX ON tbl(list); -- \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432 btree<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">WITH sch AS (   SELECT     'public'::text sch -- schema ) , def AS (   SELECT     clr.relname nmt   , cli.relname nmi   , pg_get_indexdef(cli.oid) def   , cli.oid clioid   , clr   , cli   , idx , (     SELECT       array_agg(T::text ORDER BY f.i)     FROM       (         SELECT           clr.oid rel         , i         , idx.indkey[i] ik         FROM           generate_subscripts(idx.indkey, 1) i       ) f     JOIN       pg_attribute T         ON (T.attrelid, T.attnum) = (f.rel, f.ik)   ) fld$   FROM     pg_class clr   JOIN     pg_index idx       ON idx.indrelid = clr.oid   JOIN     pg_class cli       ON cli.oid = idx.indexrelid   JOIN     pg_namespace nsp       ON nsp.oid = cli.relnamespace AND       nsp.nspname = (TABLE sch)   WHERE     NOT idx.indisunique AND     idx.indisready AND     idx.indisvalid AND     cli.relam = (       SELECT         oid       FROM         pg_am       WHERE         amname = 'btree'       LIMIT 1     )   ORDER BY     clr.relname, cli.relname ) , fld AS (   SELECT     *   , ARRAY(       SELECT         (att::pg_attribute).attname       FROM         unnest(fld$) att     ) nmf$   , ARRAY(       SELECT         (           SELECT             typname           FROM             pg_type           WHERE             oid = (att::pg_attribute).atttypid         )       FROM         unnest(fld$) att     ) tpf$   FROM     def ) SELECT   nmt , nmi , nmf$ , tpf$ , def FROM   fld WHERE   tpf$ &amp;&amp; ARRAY(     SELECT       typname     FROM       pg_type     WHERE       typname ~ '^_'   ) ORDER BY   1, 2;<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"plaintext\">nmt | nmi          | nmf$   | tpf$    | def -------------------------------------------------------- tbl | tbl_list_idx | {list} | {_int4} | CREATE INDEX ... <\/code><\/pre>\n<p>  <\/p>\n<h2>NULL-\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435<\/h2>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0430\u044f\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u00ab\u0437\u0430\u043c\u0443\u0441\u043e\u0440\u0438\u0432\u0430\u043d\u0438\u0435\u00bb \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e NULL&#8217;\u043e\u0432\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438. \u0422\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438, \u0433\u0434\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <b>\u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 NULL<\/b>. \u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u044b \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0435 \u043d\u0435\u0441\u0443\u0442, \u043d\u043e \u0432\u0440\u0435\u0434\u0430 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442.<\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u043e\u043d\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 FK-\u043f\u043e\u043b\u0435 \u0438\u043b\u0438 \u0441\u0432\u044f\u0437\u044c \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0441 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c. \u041f\u043e\u0442\u043e\u043c \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u0438\u043d\u0434\u0435\u043a\u0441, \u0447\u0442\u043e\u0431\u044b FK \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b \u0431\u044b\u0441\u0442\u0440\u043e\u2026 \u0438 \u0432\u043e\u0442 \u043e\u043d\u0438. \u0427\u0435\u043c \u0440\u0435\u0436\u0435 \u0441\u0432\u044f\u0437\u044c \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0430, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u00ab\u043c\u0443\u0441\u043e\u0440\u0430\u00bb \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441. \u0421\u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl(   id     serial       PRIMARY KEY , fk     integer ); CREATE INDEX ON tbl(fk);  INSERT INTO tbl(fk) SELECT   CASE WHEN i % 10 = 0 THEN i END FROM   generate_series(1, 1000000) i;<\/code><\/pre>\n<p>  \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u043a \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0449\u0435 \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435:<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON tbl(fk) WHERE (fk) IS NOT NULL;<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">_tmp=# \\di+ tbl*                                List of relations  Schema |      Name      | Type  |  Owner   |  Table   |  Size   | Description --------+----------------+-------+----------+----------+---------+-------------  public | tbl_fk_idx     | index | postgres | tbl      | 36 MB   |  public | tbl_fk_idx1    | index | postgres | tbl      | 2208 kB |  public | tbl_pkey       | index | postgres | tbl      | 21 MB   | <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 WHERE-\u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0432\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (\u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/dblink\">dblink<\/a>), \u0447\u0442\u043e <b>\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f<\/b>.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 NULL-\u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">WITH sch AS (   SELECT     'public'::text sch -- schema ) , def AS (   SELECT     clr.relname nmt   , cli.relname nmi   , pg_get_indexdef(cli.oid) def   , cli.oid clioid   , clr   , cli   FROM     pg_class clr   JOIN     pg_index idx       ON idx.indrelid = clr.oid   JOIN     pg_class cli       ON cli.oid = idx.indexrelid   JOIN     pg_namespace nsp       ON nsp.oid = cli.relnamespace AND       nsp.nspname = (TABLE sch)   WHERE     NOT idx.indisprimary AND     idx.indisready AND     idx.indisvalid AND     NOT EXISTS(       SELECT         NULL       FROM         pg_constraint       WHERE         conindid = cli.oid       LIMIT 1     ) AND     pg_relation_size(cli.oid) &gt; 1 &lt;&lt; 20 -- \u043c\u0435\u043d\u044c\u0448\u0435 1MB \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442   ORDER BY     clr.relname, cli.relname ) , fld AS (   SELECT     *   , regexp_replace(       CASE         WHEN def ~ ' USING btree ' THEN           regexp_replace(def, E'.* USING btree (.*?)($| WHERE .*)', E'\\\\1')       END     , E' ([a-z]*_pattern_ops|(ASC|DESC)|NULLS\\\\s?(?:FIRST|LAST))'     , ''     , 'ig'     ) fld   , CASE       WHEN def ~ ' WHERE ' THEN regexp_replace(def, E'.* WHERE ', '')     END wh   FROM     def ) , q AS (   SELECT     nmt   , $q$-- $q$ || quote_ident(nmt) || $q$       SET search_path = $q$ || quote_ident((TABLE sch)) || $q$, public;       SELECT         ARRAY[           count(*)         $q$ || string_agg(           ', coalesce(sum((' || coalesce(wh, 'TRUE') || ')::integer), 0)' || E'\\n' ||           ', coalesce(sum(((' || coalesce(wh, 'TRUE') || ') AND (' || fld || ' IS NULL))::integer), 0)' || E'\\n'         , '' ORDER BY nmi) || $q$         ]       FROM         $q$ || quote_ident((TABLE sch)) || $q$.$q$ || quote_ident(nmt) || $q$     $q$ q   , array_agg(clioid ORDER BY nmi) oid$   , array_agg(nmi ORDER BY nmi) idx$   , array_agg(fld ORDER BY nmi) fld$   , array_agg(wh ORDER BY nmi) wh$   FROM     fld   WHERE     fld IS NOT NULL   GROUP BY     1   ORDER BY     1 ) , res AS (   SELECT     *   , (       SELECT         qty       FROM         dblink(           'dbname=' || current_database() || ' port=' || current_setting('port')         , q         ) T(qty bigint[])     ) qty   FROM     q ) , iter AS (   SELECT     *   , generate_subscripts(idx$, 1) i   FROM     res ) , stat AS (   SELECT     nmt table_name   , idx$[i] index_name   , pg_relation_size(oid$[i]) index_size   , pg_size_pretty(pg_relation_size(oid$[i])) index_size_humanize   , regexp_replace(fld$[i], E'^\\\\((.*)\\\\)$', E'\\\\1') index_fields   , regexp_replace(wh$[i], E'^\\\\((.*)\\\\)$', E'\\\\1') index_cond   , qty[1] table_rec_count   , qty[i * 2] index_rec_count   , qty[i * 2 + 1] index_rec_count_null   FROM     iter ) SELECT   * , CASE     WHEN table_rec_count &gt; 0       THEN index_rec_count::double precision \/ table_rec_count::double precision * 100     ELSE 0   END::numeric(32,2) index_cover_prc , CASE     WHEN index_rec_count &gt; 0       THEN index_rec_count_null::double precision \/ index_rec_count::double precision * 100     ELSE 0   END::numeric(32,2) index_null_prc FROM   stat WHERE   index_rec_count_null * 4 &gt; index_rec_count -- \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044c NULL-\u0437\u0430\u043f\u0438\u0441\u0435\u0439 ORDER BY   1, 2;<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-[ RECORD 1 ]--------+-------------- table_name           | tbl index_name           | tbl_fk_idx index_size           | 37838848 index_size_humanize  | 36 MB index_fields         | fk index_cond           | table_rec_count      | 1000000 index_rec_count      | 1000000 index_rec_count_null | 900000 index_cover_prc      | 100.00 -- 100% \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b index_null_prc       | 90.00  -- \u0438\u0437 \u043d\u0438\u0445 90% NULL-&quot;\u043c\u0443\u0441\u043e\u0440\u0430&quot; <\/code><\/pre>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0438\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0438 \u0432\u0430\u043c.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/488104\/\"> https:\/\/habr.com\/ru\/company\/tensor\/blog\/488104\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/488104\/\">\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442, \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 PostgreSQL \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0448\u0432\u0435\u0439\u0446\u0430\u0440\u0441\u043a\u0438\u0439 \u043d\u043e\u0436, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441 \u043b\u044e\u0431\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <i><b>\u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441<\/b><\/i> \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u043b\u0438 <i><b>\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u043a\u0443\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c<\/b><\/i> \u0432 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 (\u043c\u0430\u0433\u0438\u044f-\u043c\u0430\u0433\u0438\u044f!) \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7f\/ay\/qh\/7fayqhfcbpano3cagjluq6cxary.png\"><br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442, \u0438\u043b\u0438 \u043d\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u0438\u043b\u0438 \u043d\u0435 \u0432\u0441\u0435. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043b\u0438\u0448\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u044f\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>  \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u0430\u043a\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043f\u0440\u0438 \u00ab\u0434\u043e\u043b\u0433\u043e\u0438\u0433\u0440\u0430\u044e\u0449\u0435\u0439\u00bb \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0437\u0430\u043a\u0430\u0437\u043d\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043f\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u00ab\u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0440\u0430\u0437\u043e\u0432\u043e, \u043e\u0442\u0434\u0430\u043b, \u0437\u0430\u0431\u044b\u043b\u00bb, \u0430, \u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/sbis.ru\/all_services\">\u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u0434\u043b\u0438\u043d\u043d\u044b\u043c \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c<\/a>.<\/p>\n<p>  \u0414\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0441\u0438\u043b\u0430\u043c\u0438 <a href=\"https:\/\/sbis.ru\/about\">\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u0435\u0441\u0435\u043d\u044b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u043e \u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0418 \u0442\u043e\u0433\u0434\u0430, \u043d\u0435 \u0437\u043d\u0430\u044f \u0432\u0441\u0435\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0435\u0433\u043e \u0411\u0414, \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u00ab\u043d\u0430\u043f\u043e\u0440\u0442\u0430\u0447\u0438\u0442\u044c\u00bb \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438. \u041d\u043e \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 <b>\u043f\u0440\u043e\u0432\u0435\u0440\u043e\u0447\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c<\/b> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<ul>\n<li>\u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b<\/li>\n<li>\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0435 \u00ab\u043a\u043b\u043e\u043d\u044b\u00bb<\/li>\n<li>timestamp \u00ab\u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435\u00bb<\/li>\n<li>\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u044b\u0439 boolean<\/li>\n<li>\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435<\/li>\n<li>NULL-\u043c\u0443\u0441\u043e\u0440<\/li>\n<\/ul>\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-298919","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298919","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=298919"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298919\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}