{"id":312874,"date":"2020-11-10T09:00:41","date_gmt":"2020-11-10T09:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=312874"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=312874","title":{"rendered":"PostgreSQL Antipatterns: \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043e\u0442\u0440\u0435\u0437\u043a\u0430\u043c\u0438 \u0432 \u00ab\u043a\u0440\u043e\u0432\u0430\u0432\u043e\u043c \u044d\u043d\u0442\u0435\u0440\u043f\u0440\u0430\u0439\u0437\u0435\u00bb"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0412 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0435\u0448\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e <b>\u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043e\u0442\u0440\u0435\u0437\u043a\u0430\u043c\u0438\/\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438<\/b>. \u0421\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0432 \u043d\u0438\u0445 \u2014 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ni\/zs\/ma\/nizsman2ujtuwyfkgstzmwtycvm.png\"><\/div>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u043d\u0438 \u043e\u0442\u0447\u0430\u044f\u043d\u043d\u043e \u043c\u0430\u0441\u043a\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0438 \u0434\u0430\u0436\u0435 \u0443 \u043d\u0430\u0441 \u0432 <a href=\"https:\/\/sbis.ru\/all_services\">\u0421\u0411\u0418\u0421<\/a> \u0438\u0445 \u043d\u0430\u0439\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0432 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0444\u0435\u0440\u0430\u0445 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u044f\u0442\u0438\u0435\u043c: <a href=\"https:\/\/sbis.ru\/time_management\">\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/a>, \u043e\u0446\u0435\u043d\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 <a href=\"https:\/\/sbis.ru\/cloud_pbx\">\u043b\u0438\u043d\u0438\u0439 \u0410\u0422\u0421<\/a> \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432 <a href=\"https:\/\/sbis.ru\/accounting\">\u0431\u0443\u0445\u0433\u0430\u043b\u0442\u0435\u0440\u0441\u043a\u043e\u043c \u0443\u0447\u0435\u0442\u0435<\/a>.  <\/p>\n<blockquote><p>\u00ab\u041e\u0442\u043b\u0438\u0447\u0438\u0435 enterprise [\u0440\u0435\u0448\u0435\u043d\u0438\u044f] \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u2014 \u043e\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0434\u0451\u0442 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u0438 \u0440\u0435\u0448\u0430\u0435\u0442 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447\u0443.\u00bb <a href=\"https:\/\/techquisitor.livejournal.com\/315100.html\">[src]<\/a><\/p><\/blockquote>\n<p>\u0412\u043e\u0442 \u0438 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e <b>\u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PostgreSQL<\/b> \u0438 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u043a\u0443\u043d\u0434 \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0435 \u0434\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434, \u0443\u043c\u0435\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ul>\n<li>\u043f\u043e\u0438\u0441\u043a \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432, \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0445 \u0442\u043e\u0447\u043a\u0443\/\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b<\/li>\n<li>\u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044e<\/li>\n<li>\u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041e\u0442\u0440\u0435\u0437\u043a\u0438 \u0432 \u0442\u043e\u0447\u043a\u0435<\/h2>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u043d\u0430\u0448\u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u2014 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f <b>\u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432, \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443<\/b>. \u0412 \u0431\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0430\u043a\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043b\u0438 date, \u0438\u043b\u0438 timestamp.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kj\/lj\/h0\/kjljh0jr2geagyfhgopkkiwnrca.png\"><\/p>\n<blockquote><p>\u0422\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447\u0430: <i>\u00ab\u043a\u0442\u043e \u0438\u0437 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0431\u044b\u043b \u043d\u0430 \u0431\u043e\u043b\u044c\u043d\u0438\u0447\u043d\u043e\u043c \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a?\u00bb<\/i>, <i>\u00ab\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0443\u0439\u0442\u0438 \u043d\u0430 \u043e\u0431\u0435\u0434?\u00bb<\/i> \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 <i>\u00ab\u043a\u0442\u043e \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u043c \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u044d\u0442\u043e\u0433\u043e \u0433\u043e\u0434\u0430?\u00bb<\/i>.<\/p><\/blockquote>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u0431\u043e\u043b\u044c\u043d\u0438\u0447\u043d\u044b\u0445\u00bb \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043d\u0430\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<pre><code class=\"sql\">CREATE TABLE ranges(   owner     integer , dtb -- \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0442\u0440\u0435\u0437\u043a\u0430     date , dte -- \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u0430     date );  INSERT INTO ranges(   owner , dtb , dte ) SELECT   (random() * 1e3)::integer , dtb , dtb + (random() * 1e2)::integer FROM   (     SELECT       now()::date - (random() * 1e3)::integer dtb     FROM       generate_series(1, 1e5)   ) T; <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0442\u043e \u0438\u0437 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0447\u0438\u0441\u043b\u0438\u043b\u0441\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u043d\u0438\u0447\u043d\u043e\u043c \u0432 \u043d\u043e\u0432\u043e\u0433\u043e\u0434\u043d\u044e\u044e \u043d\u043e\u0447\u044c.<\/p>\n<h4>BETWEEN + btree<\/h4>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">SELECT   * FROM   ranges WHERE   '2020-01-01'::date BETWEEN dtb AND dte;<\/code><\/pre>\n<p>  \u041d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0431\u0435\u0437 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043b\u0433\u043e \u0438 \u043f\u043b\u043e\u0445\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0438\u0441\u043a\u0443\u0448\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u00ab\u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432\u0438\u0436\u0443, \u0442\u0435 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u00bb:<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON ranges(dtb, dte);<\/code><\/pre>\n<p>  \u0418\u2026 \u044d\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0438\u043a\u0430\u043a, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u043b\u0438 \u0432\u0441\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 (100K \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 95K \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043b\u0438):<br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/bd308855d5c36b17a8371d3a544eb0a3:0:2020-11-06\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nd\/wc\/ik\/ndwcik57dyk6n0lyiuydcqcetuw.png\"><\/a><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u00ab\u043f\u043e\u0447\u0435\u043c\u0443\u00bb, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u043a\u0430\u043a \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/488104\/\">\u00abDBA: \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b\u00bb<\/a>: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>dtb<\/code> \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0440\u0430\u0432\u0430, <code>dte<\/code> \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0435\u0432\u0430, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0438\u043c\u0435\u0435\u043c <b>\u0434\u0432\u0430 \u00ab\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043d\u044b\u0445\u00bb \u043a\u043b\u044e\u0447\u0430<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u043f\u043e <b>btree<\/b> \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043b\u043e\u0445\u043e.<\/p>\n<h4>*range + GiST<\/h4>\n<p>  \u041d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0435\u0441\u0442\u044c \u2014 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/rangetypes#RANGETYPES-INDEXING\">\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/company\/postgrespro\/blog\/333878\/\">GiST-\u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/a>:<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON ranges   USING gist( -- \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c &quot;\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439&quot; GiST-\u0438\u043d\u0434\u0435\u043a\u0441     daterange(dtb, dte, '[]') -- \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0434\u0430\u0442   );<\/code><\/pre>\n<p>  \u041d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code class=\"sql\">SELECT   * FROM   ranges WHERE   daterange(dtb, dte, '[]') @&gt; '2020-01-01'::date; -- \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d<\/code><\/pre>\n<p>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/697ae8e8f2c5baf8dbe14ec2ee6e91b4:0:2020-11-06\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ym\/53\/9f\/ym539ffkxe6-fvrffuhdlqysjhy.png\"><\/a><\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 3 \u0440\u0430\u0437\u0430.<\/p>\n<h2>\u041e\u0442\u0440\u0435\u0437\u043a\u0438 \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0435<\/h2>\n<p>  \u041d\u043e \u0437\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u0432\u0441\u0435 5K \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u00ab\u0431\u043e\u043b\u044c\u043d\u0438\u0447\u043d\u044b\u0445\u00bb? \u0412\u0435\u0434\u044c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u0443 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0430\u044f-\u0442\u043e <b>\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432<\/b>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0430\u0434\u043e \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043e\u0431\u0449\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/i-\/nt\/m3\/i-ntm3q8vsd0luqzt8efv1pblmm.png\"><\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u043e\u0432:<\/p>\n<pre><code class=\"sql\">ALTER TABLE ranges ADD COLUMN segment integer; UPDATE ranges SET segment = (random() * 1e2)::integer;<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"sql\">SELECT   * FROM   ranges WHERE   segment = 1 AND   daterange(dtb, dte, '[]') @&gt; '2020-01-01'::date; <\/code><\/pre>\n<p>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/7bcb41ff5392fba238e774bbe0acf4cf:0:2020-11-09\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/un\/eh\/zm\/unehzm_xcsp8ishc-lqigliyjqe.png\"><\/a><\/p>\n<p>  \u0418\u043d\u0434\u0435\u043a\u0441, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e 99% \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0432\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0440\u044f \u2014 4945 \u0441\u0442\u0440\u043e\u043a \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u043f\u043e\u043b\u0435 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441, \u0434\u0430?..<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON ranges USING gist(segment, daterange(dtb, dte, '[]')); -- \u041e\u0428\u0418\u0411\u041a\u0410:  \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 integer \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u043a\u043b\u0430\u0441\u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 &quot;gist&quot; -- HINT:  \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/code><\/pre>\n<p>  \u0423\u0432\u044b, \u043d\u0435\u0442 \u2014 GiST-\u0438\u043d\u0434\u0435\u043a\u0441 \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a\u00bb \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438. \u0417\u0430\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/btree-gist\">btree_gist<\/a> \u2014 \u043d\u0430\u0443\u0447\u0438\u0442\u0441\u044f:<\/p>\n<pre><code class=\"sql\">CREATE EXTENSION btree_gist; CREATE INDEX ON ranges USING gist(segment, daterange(dtb, dte, '[]')); <\/code><\/pre>\n<p>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/cbb20265fbc3b6e1cc790f2fa2c4a406:0:2020-11-09\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dq\/ky\/gj\/dqkygjgfouujxjxthmofuwfri6c.png\"><\/a><\/p>\n<p>  \u041d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0441\u044f \u043e\u0442 \u0432\u0441\u0435\u0445 \u043d\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0439 \u0438 \u0441\u0442\u0430\u043b \u0432 20 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435! \u0414\u043e \u043a\u0443\u0447\u0438, \u0435\u0449\u0435 \u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u043b \u0432 10 \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (buffers).<\/p>\n<h2>\u041e\u0442\u0440\u0435\u0437\u043a\u0438 \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435<\/h2>\n<p>  \u041d\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u0441 \u0442\u043e\u0447\u043a\u043e\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0440\u0435\u0436\u0435, \u0447\u0435\u043c <b>\u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c<\/b>.  <\/p>\n<blockquote><p>\u0422\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447\u0430: &quot;<i>\u043a\u0442\u043e \u0445\u043e\u0434\u0438\u043b \u0432 \u043e\u0442\u043f\u0443\u0441\u043a \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435?<\/i>&quot;, &quot;<i>\u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043c\u043e\u0435\u043c \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0435 \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f?<\/i>&quot;<\/p><\/blockquote>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/g9\/bm\/o3\/g9bmo3ol9mqvn-5y26lkknuv7ny.png\"><\/p>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<pre><code class=\"sql\">SELECT   * FROM   ranges WHERE   segment = 1 AND   daterange(dtb, dte, '[]') &amp;&amp; daterange('2020-01-01', '2020-02-01', '[)'); -- \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432, \u0431\u0435\u0437 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b<\/code><\/pre>\n<p>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/f8f15c7c12501bff04bef24597a205db:0:2020-11-09\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-s\/ho\/0m\/-sho0mfsd8bx62kskoycxvlwxd4.png\"><\/a><\/p>\n<h2>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432<\/h2>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u0438 \u043a\u0442\u043e \u0445\u043e\u0434\u0438\u043b \u0432 \u043e\u0442\u043f\u0443\u0441\u043a \u2014 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0442\u0438\u043c \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0436\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u00ab\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0438\u0433\u0440\u0430\u043b\u0430 \u0432 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u0435\u00bb. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 <b>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044e<\/b>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tv\/6t\/os\/tv6tos3bdslkqd4qpdgfnof5o8c.png\"><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0437\u043d\u0430\u043b\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b, \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438, \u0442\u043e \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <b>\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &quot;+&quot;<\/b>:<\/p>\n<pre><code class=\"sql\">SELECT int4range('[0,2]') + int4range('[1,3]'); -- [0,4)<\/code><\/pre>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0448\u0442\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u0432\u0440\u043e\u0434\u0435 <b>range_agg \u043f\u043e\u043a\u0430 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e<\/b>. \u0415\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/schinckel.net\/2014\/11\/18\/aggregating-ranges-in-postgres\/\">\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e<\/a>, \u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u044d\u0442\u043e \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0430\u0448\u043d\u043e, \u0438 \u0431\u0430\u0437\u0443 \u0437\u0430\u0441\u043e\u0440\u044f\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u2014 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lp\/3d\/gf\/lp3dgfms2dxvxofwzxwxsrudoli.png\"><\/p>\n<p>  \u0412\u0430\u0440\u0438\u0430\u043d\u0442, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u0436\u0435 \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 8.4, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 <a href=\"https:\/\/wiki.postgresql.org\/wiki\/Range_aggregation\">PostgreSQL Wiki<\/a>:<\/p>\n<pre><code class=\"sql\">WITH rng(s, e) AS (   VALUES     ( 1,  3)   , ( 2,  4)   , ( 5,  6)   , ( 5,  8)   , ( 6,  9)   , ( 7, 10)   , ( 8, 10)   , (10, 11)   , (10, 15)   , (11, 12)   , (12, 13) ) SELECT   min(s) s , max(e) e FROM   (     SELECT       s     , e     , max(new_start) OVER(ORDER BY s, e) left_edge     FROM       (         SELECT           s         , e         , CASE             WHEN s &lt; max(le) OVER(ORDER BY s, e) THEN               NULL             ELSE               s           END new_start         FROM           (             SELECT               s             , e             , lag(e) OVER(ORDER BY s, e) le             FROM               rng           ) s1       ) s2   ) s3 GROUP BY   left_edge;<\/code><\/pre>\n<p>  \u041d\u043e \u043f\u043b\u0430\u043d \u0443 \u043d\u0435\u0433\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u2014 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430, \u0442\u0440\u0438 WindowAgg, \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0430:<\/p>\n<p>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/60317fd813d68ed4c11d97f86957973b:0:2020-11-09\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/op\/1o\/xu\/op1oxust3fjpw-vzge5wywkal3u.png\"><\/a><\/p>\n<p>  \u0418 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0442\u043e\u0447\u043a\u0435 10 \u043e\u043d \u043d\u0435 \u00ab\u0441\u043b\u0438\u0432\u0430\u0435\u0442\u00bb \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b, \u0445\u043e\u0442\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u2014 \u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0440\u043e \u043e\u0442\u043f\u0443\u0441\u043a\u0430.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441 \u0443\u0441\u0442\u0440\u043e\u0438\u0442:<\/p>\n<ol>\n<li>\u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u0438 <b>\u043f\u043e \u043f\u0430\u0440\u0435 <code>(\u043d\u0430\u0447\u0430\u043b\u043e, \u043a\u043e\u043d\u0435\u0446)<\/code><\/b>.<\/li>\n<li>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u00ab\u043d\u0430\u0447\u0430\u043b\u0430\u00bb \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u043e\u043d\u043e \u043f\u0440\u0430\u0432\u0435\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0435\u043c\u0443 \u00ab\u043a\u043e\u043d\u0446\u043e\u0432\u00bb. \u0415\u0441\u043b\u0438 \u043b\u0435\u0432\u0435\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442 \u0438\u043b\u0438 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u00ab\u043a\u043e\u043d\u0435\u0446\u00bb \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043b\u0435\u0432\u0435\u0435 \u2014 <b>\u044d\u0442\u043e \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430<\/b>.<\/li>\n<li>\u041e\u0442\u043d\u0435\u0441\u0435\u043c \u0432\u0441\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u0438 \u0432 \u0433\u0440\u0443\u043f\u043f\u044b <b>\u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u00ab\u043d\u0430\u0447\u0430\u043b\u00bb<\/b>.<\/li>\n<li>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 \u0431\u0435\u0440\u0435\u043c <b>\u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0438\u0437 \u00ab\u043d\u0430\u0447\u0430\u043b\u00bb \u0438 \u00ab\u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439\u00bb \u0438\u0437 \u043a\u043e\u043d\u0446\u043e\u0432<\/b> \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b.<\/li>\n<\/ol>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/n1\/ff\/jr\/n1ffjrbnbymtazw0dwnvjnzxntu.png\"><\/p>\n<pre><code class=\"sql\">WITH rng(s, e) AS (   VALUES     ( 1,  3)   , ( 2,  4)   , ( 5,  6)   , ( 5,  8)   , ( 6,  9)   , ( 7, 10)   , ( 8, 10)   , (10, 11)   , (10, 15)   , (11, 12)   , (12, 13) ) SELECT -- min\/max \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0435   min(s) s , max(e) e FROM   (     SELECT       *     , sum(ns::integer) OVER(ORDER BY s, e) grp -- \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0433\u0440\u0443\u043f\u043f     FROM       (         SELECT           *         , coalesce(s &gt; max(e) OVER(ORDER BY s, e ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), TRUE) ns -- \u043d\u0430\u0447\u0430\u043b\u043e \u043f\u0440\u0430\u0432\u0435\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043a\u043e\u043d\u0446\u043e\u0432 == \u0440\u0430\u0437\u0440\u044b\u0432         FROM           rng       ) t   ) t GROUP BY   grp;<\/code><\/pre>\n<p>  \u041d\u0443, \u0438 \u043e\u0434\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 WindowAgg \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u044b\u0433\u0440\u0430\u0442\u044c:<br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/139fbfb55dd844fe8e764545bb06ecc7:0:2020-11-09\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3z\/o4\/hv\/3zo4hvombgmnrzysoh_2ee_uagg.png\"><\/a><\/p>\n<h4>\u0414\u043b\u0438\u043d\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432<\/h4>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0446\u0435\u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0441\u0430\u043c\u0438 \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u0438, \u0430 \u043d\u0443\u0436\u043d\u0430 <b>\u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430<\/b>, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e WindowAgg \u0434\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430:<\/p>\n<ol>\n<li>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0440\u0435\u0437\u043a\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u00ab\u043a\u043e\u043d\u0446\u043e\u0432\u00bb \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445.<\/li>\n<li>\u0411\u0435\u0440\u0435\u043c \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0446\u043e\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u0430 \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u0430 \u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u00ab\u043a\u043e\u043d\u0446\u0430\u00bb.<\/li>\n<li>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438.<\/li>\n<\/ol>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/us\/vx\/tz\/usvxtzahnpemf63npllpirph4iw.png\"><\/p>\n<pre><code class=\"sql\">WITH rng(s, e) AS (   VALUES     ( 1,  3)   , ( 2,  4)   , ( 5,  6)   , ( 5,  8)   , ( 6,  9)   , ( 7, 10)   , ( 8, 10)   , (10, 11)   , (10, 15)   , (11, 12)   , (12, 13) ) SELECT   sum(delta) FROM   (     SELECT       *     , greatest(         e - greatest(           max(e) OVER(ORDER BY s, e ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING)         , s         )       , 0       ) delta     FROM       rng   ) T; <\/code><\/pre>\n<p><a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/c01aa2b052564fd057f513167d351dda:0:2020-11-09\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jb\/cs\/nv\/jbcsnvxkjcgpopwujlbelqfqan8.png\"><\/a><\/p>\n<p>  <i><font color=\"#808080\">\u0421\u043f\u0430\u0441\u0438\u0431\u043e <a href=\"https:\/\/habr.com\/ru\/users\/imschur\/\" class=\"user_link\">imschur<\/a> \u0437\u0430 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/font><\/i><\/p>\n<h2>\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435<\/h2>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443 \u043d\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0435 \u0432\u0441\u0435 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438. \u041d\u043e \u0432\u0435\u0434\u044c \u0438\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u0440\u0430\u0437\u043d\u043e\u0435 <b>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/b> \u2014 \u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430?  <\/p>\n<blockquote><p>\u0422\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447\u0430: \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0436\u0434\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 call-\u0446\u0435\u043d\u0442\u0440\u0430: &quot;<i>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0432\u043e\u043d\u043a\u043e\u0432 \u043c\u044b \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e? \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0432 \u043d\u043e\u0447\u043d\u043e\u0439 \u0441\u043c\u0435\u043d\u0435?<\/i>&quot;  <\/p><\/blockquote>\n<ol>\n<li>\u041f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u00ab\u043d\u0430\u0447\u0430\u043b\u0443\u00bb \u043e\u0442\u0440\u0435\u0437\u043a\u0430 \u0432\u0435\u0441 +1, \u0430 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u00ab\u043a\u043e\u043d\u0446\u0443\u00bb \u2014 -1.<\/li>\n<li>\u041f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u043c\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0438 \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/li>\n<\/ol>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fs\/cf\/sj\/fscfsjtwa6psbnz-c4ju8d6lavc.png\"><\/p>\n<pre><code class=\"sql\">WITH rng(s, e) AS (   VALUES     ( 1,  3)   , ( 2,  4)   , ( 5,  6)   , ( 5,  8)   , ( 6,  9)   , ( 7, 10)   , ( 8, 10)   , (10, 11)   , (10, 15)   , (11, 12)   , (12, 13) ) SELECT DISTINCT ON(p) -- \u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0442\u043e\u0447\u043a\u0435   p , sum(v) OVER(ORDER BY p) qty -- \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430 FROM   (     SELECT       s p     , +1 v     FROM       rng   UNION ALL     SELECT       e p     , -1 v     FROM       rng   ) T ORDER BY   1;<\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0441\u0435. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0435\u0442\u0435 \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0442\u0440\u0435\u0437\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447 \u2014 \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/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\/526624\/\"> https:\/\/habr.com\/ru\/company\/tensor\/blog\/526624\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0412 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0435\u0448\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e <b>\u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043e\u0442\u0440\u0435\u0437\u043a\u0430\u043c\u0438\/\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438<\/b>. \u0421\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0432 \u043d\u0438\u0445 \u2014 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ni\/zs\/ma\/nizsman2ujtuwyfkgstzmwtycvm.png\"><\/div>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u043d\u0438 \u043e\u0442\u0447\u0430\u044f\u043d\u043d\u043e \u043c\u0430\u0441\u043a\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0438 \u0434\u0430\u0436\u0435 \u0443 \u043d\u0430\u0441 \u0432 <a href=\"https:\/\/sbis.ru\/all_services\">\u0421\u0411\u0418\u0421<\/a> \u0438\u0445 \u043d\u0430\u0439\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0432 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0444\u0435\u0440\u0430\u0445 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u044f\u0442\u0438\u0435\u043c: <a href=\"https:\/\/sbis.ru\/time_management\">\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/a>, \u043e\u0446\u0435\u043d\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 <a href=\"https:\/\/sbis.ru\/cloud_pbx\">\u043b\u0438\u043d\u0438\u0439 \u0410\u0422\u0421<\/a> \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432 <a href=\"https:\/\/sbis.ru\/accounting\">\u0431\u0443\u0445\u0433\u0430\u043b\u0442\u0435\u0440\u0441\u043a\u043e\u043c \u0443\u0447\u0435\u0442\u0435<\/a>.  <\/p>\n<blockquote><p>\u00ab\u041e\u0442\u043b\u0438\u0447\u0438\u0435 enterprise [\u0440\u0435\u0448\u0435\u043d\u0438\u044f] \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u2014 \u043e\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0434\u0451\u0442 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u0438 \u0440\u0435\u0448\u0430\u0435\u0442 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u0437\u0430\u0434\u0430\u0447\u0443.\u00bb <a href=\"https:\/\/techquisitor.livejournal.com\/315100.html\">[src]<\/a><\/p><\/blockquote>\n<p>\u0412\u043e\u0442 \u0438 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e <b>\u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PostgreSQL<\/b> \u0438 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u043a\u0443\u043d\u0434 \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0435 \u0434\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434, \u0443\u043c\u0435\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ul>\n<li>\u043f\u043e\u0438\u0441\u043a \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432, \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0445 \u0442\u043e\u0447\u043a\u0443\/\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b<\/li>\n<li>\u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044e<\/li>\n<li>\u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435<\/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-312874","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312874","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=312874"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312874\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}