{"id":300763,"date":"2020-03-26T09:00:36","date_gmt":"2020-03-26T09:00:36","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=300763"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=300763","title":{"rendered":"\u0420\u0435\u0446\u0435\u043f\u0442\u044b \u0434\u043b\u044f \u0445\u0432\u043e\u0440\u0430\u044e\u0449\u0438\u0445 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/492694\/\">\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/477624\/\">\u043c\u044b \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0438 <i><b>explain.tensor.ru<\/b><\/i><\/a> \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/explain.tensor.ru\/\">\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043b\u0430\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/a> \u043a PostgreSQL.<\/p>\n<p>  \u0417\u0430 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b \u0443\u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0438\u043c \u0431\u043e\u043b\u0435\u0435 6000 \u0440\u0430\u0437, \u043d\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043e\u0433\u043b\u0430 \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0439 \u2014 \u044d\u0442\u043e <b>\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jp\/66\/1s\/jp661svgeudxc0wvgnzqoyjffbc.png\"><\/p>\n<p>  \u041f\u0440\u0438\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0438\u043c, \u0438 \u0432\u0430\u0448\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u00ab\u0441\u0442\u0430\u043d\u0443\u0442 \u0433\u043b\u0430\u0434\u043a\u0438\u043c\u0438 \u0438 \u0448\u0435\u043b\u043a\u043e\u0432\u0438\u0441\u0442\u044b\u043c\u0438\u00bb. \ud83d\ude42<\/p>\n<p>  \u0410 \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e, \u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c \u0438 \u00ab\u043f\u0440\u043e\u0436\u043e\u0440\u043b\u0438\u0432\u044b\u043c\u00bb \u043f\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, <b>\u0442\u0438\u043f\u0438\u0447\u043d\u044b \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u044b \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0438 \u0434\u0430\u043d\u043d\u044b\u043c \u043f\u043b\u0430\u043d\u0430<\/b>.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0441\u0432\u043e\u0439 \u043e\u043f\u044b\u0442 \u2014 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u043c\u0443 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0432 \u0447\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0430, \u0438 <b>\u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e<\/b>. \u0427\u0442\u043e \u043c\u044b \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/up\/br\/mr\/upbrmra7tcpkdnygwg0abfhbqse.png\"><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0447\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u0438 \u043a\u0435\u0439\u0441\u044b \u2014 \u043a\u0430\u043a \u043e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u043a \u043a\u0430\u043a\u0438\u043c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f\u043c \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0432 \u0442\u0435\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0431\u043b\u043e\u043a \u0438\u0437 <a href=\"https:\/\/pgconf.ru\/2020\/262963\">\u043c\u043e\u0435\u0433\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u043d\u0430 PGConf.Russia 2020<\/a>, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/jHqaLp040rY?rel=0&amp;showinfo=1&amp;start=1190&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2><font color=\"#c00000\">#1: \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u0430\u044f \u00ab\u043d\u0435\u0434\u043e\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u00bb<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0447\u0435\u0442 \u043f\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u00ab\u041e\u041e\u041e \u041a\u043e\u043b\u043e\u043a\u043e\u043b\u044c\u0447\u0438\u043a\u00bb.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; Limit    -&gt; Sort       -&gt; Index [Only] Scan [Backward] | Bitmap Heap Scan <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 <b>\u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043f\u043e\u043b\u044f\u043c\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438<\/b>.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl AS SELECT   generate_series(1, 100000) pk  -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot; , (random() * 1000)::integer fk_cli; -- 1K \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439  CREATE INDEX ON tbl(fk_cli); -- \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f foreign key  SELECT   * FROM   tbl WHERE   fk_cli = 1 -- \u043e\u0442\u0431\u043e\u0440 \u043f\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 ORDER BY   pk DESC -- \u0445\u043e\u0442\u0438\u043c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 &quot;\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e&quot; \u0437\u0430\u043f\u0438\u0441\u044c LIMIT 1;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nn\/u1\/wp\/nnu1wpmpqryyy3rrpmhpofv1izk.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/f493a380e786374ae517340ed3198200:0:2020-03-20\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0432\u044b\u0447\u0438\u0442\u0430\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0435 100 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0442\u043e\u043c \u0432\u0441\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c, \u0430 \u043f\u043e\u0442\u043e\u043c \u0431\u044b\u043b\u0430 \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f.<\/p>\n<p>  \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"sql\">DROP INDEX tbl_fk_cli_idx; CREATE INDEX ON tbl(fk_cli, pk DESC); -- \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043a\u043b\u044e\u0447 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gv\/ny\/ni\/gvnyniyvlmcsfk-f2qk4voomvzo.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/4e63f9e50ff91af0cbd662c6c438af6e:0:2020-03-20\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0414\u0430\u0436\u0435 \u043d\u0430 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u2014 <b>\u0432 8.5 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0432 33 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0442\u0435\u043d\u0438\u0439<\/b>. \u042d\u0444\u0444\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0443 \u0432\u0430\u0441 \u00ab\u0444\u0430\u043a\u0442\u043e\u0432\u00bb \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e <code>fk<\/code>.<\/p>\n<p>  \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u00ab\u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0439\u00bb \u043d\u0435 \u0445\u0443\u0436\u0435 \u043f\u0440\u0435\u0436\u043d\u0435\u0433\u043e \u0438 \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u0441 <code>fk<\/code>, \u0433\u0434\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e <code>pk<\/code> \u043d\u0435 \u0431\u044b\u043b\u043e \u0438 \u043d\u0435\u0442 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/488104\/\">\u0432 \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e \u043f\u043e\u0438\u0441\u043a \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/a>). \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u043e\u043d \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442 \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e <b>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u044f\u0432\u043d\u043e\u0433\u043e foreign key<\/b> \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044e.<\/p>\n<h2><font color=\"#c00000\">#2: \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 (BitmapAnd)<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u044b \u043f\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u00ab\u041e\u041e\u041e \u041a\u043e\u043b\u043e\u043a\u043e\u043b\u044c\u0447\u0438\u043a\u00bb, \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u00ab\u041d\u0410\u041e \u041b\u044e\u0442\u0438\u043a\u00bb.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; BitmapAnd    -&gt; Bitmap Index Scan    -&gt; Bitmap Index Scan<\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0442\u044c <b>\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441<\/b> \u043f\u043e \u043f\u043e\u043b\u044f\u043c \u0438\u0437 \u043e\u0431\u043e\u0438\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0438\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u043b\u044f\u043c\u0438 \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0433\u043e.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl AS SELECT   generate_series(1, 100000) pk      -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot; , (random() *  100)::integer fk_org  -- 100 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 , (random() * 1000)::integer fk_cli; -- 1K \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439  CREATE INDEX ON tbl(fk_org); -- \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f foreign key CREATE INDEX ON tbl(fk_cli); -- \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f foreign key  SELECT   * FROM   tbl WHERE   (fk_org, fk_cli) = (1, 999); -- \u043e\u0442\u0431\u043e\u0440 \u043f\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043f\u0430\u0440\u0435<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dh\/y4\/mz\/dhy4mzknpsqyk3ejuetev5mlmiy.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/299b8241cf0f2ca384a40b59184995a7:0:2020-03-20\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"sql\">DROP INDEX tbl_fk_org_idx; CREATE INDEX ON tbl(fk_org, fk_cli); <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vt\/nm\/2c\/vtnm2csqildllccdfsffjgxu4ya.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/b93575fd1d7d96c91fa861899686ec45:0:2020-03-20\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0422\u0443\u0442 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u043c\u0435\u043d\u044c\u0448\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 Bitmap Heap Scan \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435. \u041d\u043e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 <b>\u0432 7 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0432 2.5 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0442\u0435\u043d\u0438\u0439<\/b>.<\/p>\n<h2><font color=\"#c00000\">#3: \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 (BitmapOr)<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 20 \u0441\u0430\u043c\u044b\u0445 \u0441\u0442\u0430\u0440\u044b\u0445 \u00ab\u0441\u0432\u043e\u0438\u0445\u00bb \u0438\u043b\u0438 \u043d\u0435\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u044f\u0432\u043e\u043a \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043f\u0440\u0438\u0447\u0435\u043c \u0441\u0432\u043e\u0438 \u0432 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0435.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; BitmapOr    -&gt; Bitmap Index Scan    -&gt; Bitmap Index Scan<\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>UNION [ALL]<\/b> \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 OR-\u0431\u043b\u043e\u043a\u043e\u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u0439.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl AS SELECT   generate_series(1, 100000) pk  -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot; , CASE     WHEN random() &lt; 1::real\/16 THEN NULL -- \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e 1:16 \u0437\u0430\u043f\u0438\u0441\u044c &quot;\u043d\u0438\u0447\u044c\u044f&quot;     ELSE (random() * 100)::integer -- 100 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439   END fk_own;  CREATE INDEX ON tbl(fk_own, pk); -- \u0438\u043d\u0434\u0435\u043a\u0441 \u0441 &quot;\u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0439&quot; \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043e\u0439  SELECT   * FROM   tbl WHERE   fk_own = 1 OR -- \u0441\u0432\u043e\u0438   fk_own IS NULL -- ... \u0438\u043b\u0438 &quot;\u043d\u0438\u0447\u044c\u0438&quot; ORDER BY   pk , (fk_own = 1) DESC -- \u0441\u043d\u0430\u0447\u0430\u043b\u0430 &quot;\u0441\u0432\u043e\u0438&quot; LIMIT 20; <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7k\/n2\/d1\/7kn2d1ko1hrbobs44a69hasatcs.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/97301948cbe2e0b72f8d8640451a6a54:0:2020-03-23\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"sql\">(   SELECT     *   FROM     tbl   WHERE     fk_own = 1 -- \u0441\u043d\u0430\u0447\u0430\u043b\u0430 &quot;\u0441\u0432\u043e\u0438&quot; 20   ORDER BY     pk   LIMIT 20 ) UNION ALL (   SELECT     *   FROM     tbl   WHERE     fk_own IS NULL -- \u043f\u043e\u0442\u043e\u043c &quot;\u043d\u0438\u0447\u044c\u0438&quot; 20   ORDER BY     pk   LIMIT 20 ) LIMIT 20; -- \u043d\u043e \u0432\u0441\u0435\u0433\u043e - 20, \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u043d\u0435 \u043d\u0430\u0434\u043e<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/pa\/ej\/2f\/paej2f1lpkzhinvlz64tvf9n8ti.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/59dfaabee4a23b0ed1e56bbd103d676b:0:2020-03-23\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u041c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 20 \u043d\u0443\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0431\u044b\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0443\u0436\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0431\u043b\u043e\u043a\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0442\u043e\u0440\u043e\u0439, \u0441 \u0431\u043e\u043b\u0435\u0435 \u00ab\u0434\u043e\u0440\u043e\u0433\u0438\u043c\u00bb Bitmap Heap Scan, \u0434\u0430\u0436\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u2014 \u0432 \u0438\u0442\u043e\u0433\u0435 <b>\u0432 22 \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0432 44 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0442\u0435\u043d\u0438\u0439<\/b>!<\/p>\n<blockquote><p>\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 <b>\u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445<\/b> \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 <a href=\"https:\/\/habr.com\/ru\/post\/479508\/\">PostgreSQL Antipatterns: \u0432\u0440\u0435\u0434\u043d\u044b\u0435 JOIN \u0438 OR<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/491162\/\">PostgreSQL Antipatterns: \u0441\u043a\u0430\u0437 \u043e\u0431 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e, \u0438\u043b\u0438 \u00ab\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u00bb<\/a>.<\/p>\n<p>  \u041e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <b>\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043a\u043b\u044e\u0447\u0430\u043c<\/b> (\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0430\u0440\u0435 const\/NULL) \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/486072\/\">SQL HowTo: \u043f\u0438\u0448\u0435\u043c while-\u0446\u0438\u043a\u043b \u043f\u0440\u044f\u043c\u043e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u0438\u043b\u0438 \u00ab\u042d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u0430\u044f \u0442\u0440\u0435\u0445\u0445\u043e\u0434\u043e\u0432\u043a\u0430\u00bb<\/a>.<\/p><\/blockquote>\n<p>  <\/p>\n<h2><font color=\"#c00000\">#4: \u0447\u0438\u0442\u0430\u0435\u043c \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u00ab\u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0444\u0438\u043b\u044c\u0442\u0440\u00bb \u043a \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443.  <\/p>\n<blockquote><p>\u00ab\u0410 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435, \u043d\u043e <i>\u0441 \u043f\u0435\u0440\u043b\u0430\u043c\u0443\u0442\u0440\u043e\u0432\u044b\u043c\u0438 \u043f\u0443\u0433\u043e\u0432\u0438\u0446\u0430\u043c\u0438<\/i>?\u00bb <i>\u0445\/\u0444 \u00ab\u0411\u0440\u0438\u043b\u043b\u0438\u0430\u043d\u0442\u043e\u0432\u0430\u044f \u0440\u0443\u043a\u0430\u00bb<\/i>  <\/p><\/blockquote>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044f \u0437\u0430\u0434\u0430\u0447\u0443 \u0432\u044b\u0448\u0435, \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 20 \u0441\u0430\u043c\u044b\u0445 \u0441\u0442\u0430\u0440\u044b\u0445 \u00ab\u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445\u00bb \u0437\u0430\u044f\u0432\u043e\u043a \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0438\u0445 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; Seq Scan | Bitmap Heap Scan | Index [Only] Scan [Backward]    &amp;&amp; 5 \u00d7 rows &lt; RRbF -- \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043e &gt;80% \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0433\u043e    &amp;&amp; loops \u00d7 RRbF &gt; 100 -- \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0435 100 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0442\u044c [\u0431\u043e\u043b\u0435\u0435] \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <b>\u0438\u043d\u0434\u0435\u043a\u0441 \u0441 WHERE-\u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c<\/b> \u0438\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f.  <\/p>\n<blockquote><p>\u0415\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u043c\u00bb \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c <b>\u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/b> \u043f\u0435\u0440\u0435\u0447\u043d\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u2014 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c WHERE-\u0438\u043d\u0434\u0435\u043a\u0441. \u0412 \u044d\u0442\u0443 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u0445\u043e\u0440\u043e\u0448\u043e \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0435 boolean\/enum-\u0441\u0442\u0430\u0442\u0443\u0441\u044b.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 <b>\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/b>, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u2014 \u043a\u0430\u043a \u0432 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441 BitmapAnd \u0432\u044b\u0448\u0435.<\/p><\/blockquote>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl AS SELECT   generate_series(1, 100000) pk -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot; , CASE     WHEN random() &lt; 1::real\/16 THEN NULL     ELSE (random() * 100)::integer -- 100 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439   END fk_own , (random() &lt; 1::real\/50) critical; -- 1:50, \u0447\u0442\u043e \u0437\u0430\u044f\u0432\u043a\u0430 &quot;\u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430\u044f&quot;  CREATE INDEX ON tbl(pk); CREATE INDEX ON tbl(fk_own, pk);  SELECT   * FROM   tbl WHERE   critical ORDER BY   pk LIMIT 20;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ca\/lg\/hn\/calghnldd9_313mns2a535sjwma.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/4b4172ef34f8ab9dba6047c8843eccb6:0:2020-03-24\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON tbl(pk)   WHERE critical; -- \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 &quot;\u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0435&quot; \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/op\/t2\/u4\/opt2u4yh2mzocmdot9qovn6pzgu.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/21bd42b7816cbfa76598624c0338139c:0:2020-03-24\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u0438\u0437 \u043f\u043b\u0430\u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0448\u043b\u0430, \u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u0442\u0430\u043b <b>\u0432 5 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435<\/b>.<\/p>\n<h2><font color=\"#c00000\">#5: \u0440\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u0420\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0439 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u00ab\u043c\u0435\u0440\u0442\u0432\u044b\u0445\u00bb \u0437\u0430\u043f\u0438\u0441\u0435\u0439.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; Seq Scan | Bitmap Heap Scan | Index [Only] Scan [Backward]    &amp;&amp; loops \u00d7 (rows + RRbF) &lt; (shared hit + shared read) \u00d7 8       -- \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 1KB \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c    &amp;&amp; shared hit + shared read &gt; 64 <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c <b>VACUUM [FULL]<\/b> \u0438\u043b\u0438 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e \u0447\u0430\u0441\u0442\u043e\u0439 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/routine-vacuuming#AUTOVACUUM\">autovacuum<\/a> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u043e\u043d\u043a\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/sql-createtable#SQL-CREATETABLE-STORAGE-PARAMETERS\">\u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/a>.  <\/p>\n<blockquote><p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u044b\u0437\u0432\u0430\u043d\u044b \u043f\u043b\u043e\u0445\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u0432\u0440\u043e\u0434\u0435 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/491366\/\">PostgreSQL Antipatterns: \u0441\u0440\u0430\u0436\u0430\u0435\u043c\u0441\u044f \u0441 \u043e\u0440\u0434\u0430\u043c\u0438 \u00ab\u043c\u0435\u0440\u0442\u0432\u0435\u0446\u043e\u0432\u00bb<\/a>.<\/p>\n<p>  \u041d\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 VACUUM FULL \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0441\u0442\u043e\u0438\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/481866\/\">DBA: \u043a\u043e\u0433\u0434\u0430 \u043f\u0430\u0441\u0443\u0435\u0442 VACUUM \u2014 \u0447\u0438\u0441\u0442\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432\u0440\u0443\u0447\u043d\u0443\u044e<\/a>.<\/p><\/blockquote>\n<p>  <\/p>\n<h2><font color=\"#c00000\">#6: \u0447\u0442\u0435\u043d\u0438\u0435 \u0441 \u00ab\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b\u00bb \u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u0438 \u0432\u0441\u0435 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443, \u0438 \u043d\u0438\u043a\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043d\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043b\u0438 \u2014 \u0430 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0447\u0435\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; Index [Only] Scan [Backward]    &amp;&amp; loops \u00d7 (rows + RRbF) &lt; (shared hit + shared read) \u00d7 8       -- \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 1KB \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c    &amp;&amp; shared hit + shared read &gt; 64 <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043f\u043e\u043b\u044f, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u2014 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, <b>\u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0435 \u0437\u0430\u0434\u0430\u043d\u0430<\/b>. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441, \u043d\u043e \u0431\u0435\u0437 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/486072\/\">\u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/a>.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl AS SELECT   generate_series(1, 100000) pk      -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot; , (random() *  100)::integer fk_org  -- 100 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 , (random() * 1000)::integer fk_cli; -- 1K \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439  CREATE INDEX ON tbl(fk_org, fk_cli); -- \u0432\u0441\u0435 \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u043a \u0432 #2 -- \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e fk_cli \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u043b\u0438\u0448\u043d\u0438\u043c \u0438 \u0443\u0434\u0430\u043b\u0438\u043b\u0438  SELECT   * FROM   tbl WHERE   fk_cli = 999 -- \u0430 fk_org \u043d\u0435 \u0437\u0430\u0434\u0430\u043d\u043e, \u0445\u043e\u0442\u044f \u0441\u0442\u043e\u0438\u0442 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 LIMIT 20;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tl\/py\/lb\/tlpylbllwrea5ilsf-epratclha.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/ab23f8304438c198882bbc5a48a32104:0:2020-03-24\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \u0434\u0430\u0436\u0435 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443, \u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u2014 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 20 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e 4 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u0430\u043d\u043d\u044b\u0445, 32KB \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u2014 \u043d\u0435 \u0436\u0438\u0440\u043d\u043e \u043b\u0438? \u0414\u0430 \u0438 \u0438\u043c\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 <code>tbl_<b>fk_org<\/b>_fk_cli_idx<\/code> \u043d\u0430\u0432\u043e\u0434\u0438\u0442 \u043d\u0430 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON tbl(fk_cli);<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/n9\/5x\/uz\/n95xuzh7tcrmlv3eqg-bq2axhk4.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/61de235d585277b70ce761ef24f0d12c:0:2020-03-24\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0412\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u2014 <b>\u0432 10 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0438 \u0432 4 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0438\u0442\u0430\u0442\u044c<\/b>!  <\/p>\n<blockquote><p>\u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/488104\/\">DBA: \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<\/a>.<\/p><\/blockquote>\n<p>  <\/p>\n<h2><font color=\"#c00000\">#7: CTE \u00d7 CTE<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u0412 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 <b>\u043d\u0430\u0431\u0440\u0430\u043b\u0438 \u00ab\u0436\u0438\u0440\u043d\u044b\u0445\u00bb CTE<\/b> \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u0430 \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 <code>JOIN<\/code>.<\/p>\n<p>  <i>\u041a\u0435\u0439\u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0439 \u043d\u0438\u0436\u0435 v12 \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 <code>WITH MATERIALIZED<\/code>.<\/i><\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; CTE Scan    &amp;&amp; loops &gt; 10    &amp;&amp; loops \u00d7 (rows + RRbF) &gt; 10000       -- \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0434\u0435\u043a\u0430\u0440\u0442\u043e\u0432\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 CTE <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u2014 \u0430 <a href=\"https:\/\/habr.com\/ru\/post\/479298\/\">\u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u0442\u0443\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 CTE<\/a>? \u0415\u0441\u043b\u0438 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0434\u0430, \u0442\u043e <b>\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u00ab\u043e\u0441\u043b\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u043d\u0438\u0435\u00bb \u0432 hstore\/json<\/b> \u043f\u043e \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/485398\/\">PostgreSQL Antipatterns: \u0443\u0434\u0430\u0440\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u043c \u043f\u043e \u0442\u044f\u0436\u0435\u043b\u043e\u043c\u0443 JOIN<\/a>.<\/p>\n<h2><font color=\"#c00000\">#8: swap \u043d\u0430 \u0434\u0438\u0441\u043a (temp written)<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u0420\u0430\u0437\u043e\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 (\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u043b\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f) \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435 \u0432\u043b\u0435\u0437\u0430\u0435\u0442 \u0432 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; *    &amp;&amp; temp written &gt; 0<\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/runtime-config-resource#GUC-WORK-MEM\">work_mem<\/a>, \u0441\u0442\u043e\u0438\u0442 \u0435\u0433\u043e \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445, \u0430 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 <code>SET [LOCAL]<\/code> \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430\/\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">SHOW work_mem; -- &quot;16MB&quot;  SELECT   random() FROM   generate_series(1, 1000000) ORDER BY   1;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/x-\/mu\/my\/x-mumysko4noy3qy8qhdk0fecpq.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/a9672815683af9d472edde0a65ac0221:0:2020-03-24\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"sql\">SET work_mem = '128MB'; -- \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/h0\/4z\/kx\/h04zkxsgcscgj8yxdasba8jdi2s.png\"><br \/>  <a href=\"https:\/\/explain.tensor.ru\/archive\/explain\/ad4c74439394a0f6b3c32efdda9b97d1:0:2020-03-24\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/p>\n<p>  \u041f\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u043c\u044f\u0442\u044c, \u0430 \u043d\u0435 \u0434\u0438\u0441\u043a, \u0442\u043e \u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0449\u0435 \u0438 \u0447\u0430\u0441\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441 HDD \u0441\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u041d\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e-\u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u043e\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u2014 \u0435\u0435 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442 \u043d\u0430 \u0432\u0441\u0435\u0445.<\/p>\n<h2><font color=\"#c00000\">#9: \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u0412 \u0431\u0430\u0437\u0443 \u0432\u043b\u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u043d\u0435 \u0443\u0441\u043f\u0435\u043b\u0438 \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c <code>ANALYZE<\/code>.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; Seq Scan | Bitmap Heap Scan | Index [Only] Scan [Backward]    &amp;&amp; ratio &gt;&gt; 10<\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0441\u0442\u0438-\u0442\u0430\u043a\u0438 <code>ANALYZE<\/code>.  <\/p>\n<blockquote><p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/479656\/\">PostgreSQL Antipatterns: \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0432\u0441\u0435\u043c\u0443 \u0433\u043e\u043b\u043e\u0432\u0430<\/a>.<\/p><\/blockquote>\n<p>  <\/p>\n<h2><font color=\"#c00000\">#10: \u00ab\u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a\u00bb<\/font><\/h2>\n<p>  <\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>  \u0421\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u0438\u043b\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u043b\u043e \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 CPU\/\u0433\u0438\u043f\u0435\u0440\u0432\u0438\u0437\u043e\u0440\u0430.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043f\u043e\u0437\u043d\u0430\u0442\u044c<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">-&gt; *    &amp;&amp; (shared hit \/ 8K) + (shared read \/ 1K) &lt; time \/ 1000       -- RAM hit = 64MB\/s, HDD read = 8MB\/s    &amp;&amp; time &gt; 100ms -- \u0447\u0438\u0442\u0430\u043b\u0438 \u043c\u0430\u043b\u043e, \u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043e\u043b\u0433\u043e <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0432\u043d\u0435\u0448\u043d\u044e\u044e <b>\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430<\/b> \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0438\u043b\u0438 \u043d\u0435\u0448\u0442\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041f\u0440\u043e \u043d\u0430\u0448 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0434\u043b\u044f \u0441\u043e\u0442\u0435\u043d \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/328920\/\">\u0442\u0443\u0442<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/329694\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ts\/bi\/9s\/tsbi9svuilrqhgpgftjytkknpk4.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/h7\/zm\/6d\/h7zm6d-va_yx8g0mtxbdkyevcwq.png\"><\/div>\n<\/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\/492694\/\"> https:\/\/habr.com\/ru\/company\/tensor\/blog\/492694\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/492694\/\">\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 <a href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/477624\/\">\u043c\u044b \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0438 <i><b>explain.tensor.ru<\/b><\/i><\/a> \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/explain.tensor.ru\/\">\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043b\u0430\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/a> \u043a PostgreSQL.<\/p>\n<p>  \u0417\u0430 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b \u0443\u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0438\u043c \u0431\u043e\u043b\u0435\u0435 6000 \u0440\u0430\u0437, \u043d\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043e\u0433\u043b\u0430 \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0439 \u2014 \u044d\u0442\u043e <b>\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jp\/66\/1s\/jp661svgeudxc0wvgnzqoyjffbc.png\"><\/p>\n<p>  \u041f\u0440\u0438\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0438\u043c, \u0438 \u0432\u0430\u0448\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u00ab\u0441\u0442\u0430\u043d\u0443\u0442 \u0433\u043b\u0430\u0434\u043a\u0438\u043c\u0438 \u0438 \u0448\u0435\u043b\u043a\u043e\u0432\u0438\u0441\u0442\u044b\u043c\u0438\u00bb. \ud83d\ude42<\/p>\n<p>  \u0410 \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e, \u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c \u0438 \u00ab\u043f\u0440\u043e\u0436\u043e\u0440\u043b\u0438\u0432\u044b\u043c\u00bb \u043f\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, <b>\u0442\u0438\u043f\u0438\u0447\u043d\u044b \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u044b \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0438 \u0434\u0430\u043d\u043d\u044b\u043c \u043f\u043b\u0430\u043d\u0430<\/b>.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0441\u0432\u043e\u0439 \u043e\u043f\u044b\u0442 \u2014 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u043c\u0443 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0432 \u0447\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0430, \u0438 <b>\u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e<\/b>. \u0427\u0442\u043e \u043c\u044b \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/up\/br\/mr\/upbrmra7tcpkdnygwg0abfhbqse.png\"><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0447\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u0438 \u043a\u0435\u0439\u0441\u044b \u2014 \u043a\u0430\u043a \u043e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u043a \u043a\u0430\u043a\u0438\u043c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f\u043c \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442.  <\/p>\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-300763","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300763","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=300763"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300763\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=300763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=300763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=300763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}