{"id":75688,"date":"2020-03-27T19:42:35","date_gmt":"2020-03-27T17:42:35","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/reczepty-dlya-hvorayushhih-sql-zaprosov"},"modified":"2020-03-27T19:42:35","modified_gmt":"2020-03-27T17:42:35","slug":"reczepty-dlya-hvorayushhih-sql-zaprosov","status":"publish","type":"post","link":"https:\/\/prohoster.info\/it\/blog\/administrirovanie\/reczepty-dlya-hvorayushhih-sql-zaprosov","title":{"rendered":"Ricette per interrogazioni SQL problematiche","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 <noindex><a rel=\"nofollow\" 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><\/noindex> \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 <noindex><a rel=\"nofollow\" 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><\/noindex> \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\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/58df2a03e1ab8d1cfad18582c0be05db.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n\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\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/d57eff947b6708bfc4674cacc8a6a590.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n\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 \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\n\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 <noindex><a rel=\"nofollow\" href=\"https:\/\/pgconf.ru\/2020\/262963\">\u043c\u043e\u0435\u0433\u043e \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u043d\u0430 PGConf.Russia 2020<\/a><\/noindex>, \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<p><center><div class=\"youtube-placeholder\" data-id=\"jHqaLp040rY\" onclick=\"loadVideo(this)\">\r\n        <img decoding=\"async\" src=\"https:\/\/img.youtube.com\/vi\/jHqaLp040rY\/hqdefault.jpg\" alt=\"Play video\" loading=\"lazy\" width=\"480\" height=\"360\" style=\"width:100%;height:auto;\">\r\n        <div class=\"play-button\"><\/div>\r\n    <\/div><\/center><\/p>\n<h2>#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<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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\n   -&gt; Sort\n      -&gt; Index [Only] Scan [Backward] | Bitmap Heap Scan\n<\/code><\/pre>\n<p><\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>\n\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\nSELECT\n  generate_series(1, 100000) pk  -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot;\n, (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\n\nCREATE INDEX ON tbl(fk_cli); -- \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f foreign key\n\nSELECT\n  *\nFROM\n  tbl\nWHERE\n  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\nORDER BY\n  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\nLIMIT 1;<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/c7099b4707add045c96b5077804a01bb.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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;\nCREATE 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\n<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/774291adac876af2ac36703a6e416dcc.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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 <noindex><a rel=\"nofollow\" 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><\/noindex>). \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>#2: \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 (BitmapAnd)<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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\n   -&gt; Bitmap Index Scan\n   -&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>\n\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\nSELECT\n  generate_series(1, 100000) pk      -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot;\n, (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\n, (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\n\nCREATE INDEX ON tbl(fk_org); -- \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f foreign key\nCREATE INDEX ON tbl(fk_cli); -- \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f foreign key\n\nSELECT\n  *\nFROM\n  tbl\nWHERE\n  (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>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/73da65adb217b26e312134318509c3ff.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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;\nCREATE INDEX ON tbl(fk_org, fk_cli);\n<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/0ae5217d40159c10978752cb6ab0de80.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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>#3: \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 (BitmapOr)<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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\n   -&gt; Bitmap Index Scan\n   -&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>\n\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\nSELECT\n  generate_series(1, 100000) pk  -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot;\n, CASE\n    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;\n    ELSE (random() * 100)::integer -- 100 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439\n  END fk_own;\n\nCREATE 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\n\nSELECT\n  *\nFROM\n  tbl\nWHERE\n  fk_own = 1 OR -- \u0441\u0432\u043e\u0438\n  fk_own IS NULL -- ... \u0438\u043b\u0438 &quot;\u043d\u0438\u0447\u044c\u0438&quot;\nORDER BY\n  pk\n, (fk_own = 1) DESC -- \u0441\u043d\u0430\u0447\u0430\u043b\u0430 &quot;\u0441\u0432\u043e\u0438&quot;\nLIMIT 20;\n<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/c9520959f93d282a7a81d5d0acf97a09.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"sql\">(\n  SELECT\n    *\n  FROM\n    tbl\n  WHERE\n    fk_own = 1 -- \u0441\u043d\u0430\u0447\u0430\u043b\u0430 &quot;\u0441\u0432\u043e\u0438&quot; 20\n  ORDER BY\n    pk\n  LIMIT 20\n)\nUNION ALL\n(\n  SELECT\n    *\n  FROM\n    tbl\n  WHERE\n    fk_own IS NULL -- \u043f\u043e\u0442\u043e\u043c &quot;\u043d\u0438\u0447\u044c\u0438&quot; 20\n  ORDER BY\n    pk\n  LIMIT 20\n)\nLIMIT 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>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/d9d1657b7fc4ff6c33c54d40fe9e5e72.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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 <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/479508\/\">PostgreSQL Antipatterns: \u0432\u0440\u0435\u0434\u043d\u044b\u0435 JOIN \u0438 OR<\/a><\/noindex> \u0438 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/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 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/p><\/blockquote>\n<p><\/p>\n<h2>#4: \u0447\u0438\u0442\u0430\u0435\u043c \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0433\u043e<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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>\n<\/p><\/blockquote>\n<p>\n\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]\n   &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\n   &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\n<\/code><\/pre>\n<p><\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>\n\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>\n\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl AS\nSELECT\n  generate_series(1, 100000) pk -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot;\n, CASE\n    WHEN random() &lt; 1::real\/16 THEN NULL\n    ELSE (random() * 100)::integer -- 100 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439\n  END fk_own\n, (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;\n\nCREATE INDEX ON tbl(pk);\nCREATE INDEX ON tbl(fk_own, pk);\n\nSELECT\n  *\nFROM\n  tbl\nWHERE\n  critical\nORDER BY\n  pk\nLIMIT 20;<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/e73765ba80c06c3bb35f9d2392a0be5d.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c:<\/p>\n<pre><code class=\"sql\">CREATE INDEX ON tbl(pk)\n  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\n<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/e9daf79c71ec463a93604eb4b9d86c96.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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>#5: \u0440\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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]\n   &amp;&amp; loops \u00d7 (rows + RRbF) &lt; (shared hit + shared read) \u00d7 8\n      -- \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\n   &amp;&amp; shared hit + shared read &gt; 64\n<\/code><\/pre>\n<p><\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>\n\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 <noindex><a rel=\"nofollow\" href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/routine-vacuuming#AUTOVACUUM\">autovacuum<\/a><\/noindex> \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 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/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 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/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 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/p><\/blockquote>\n<p><\/p>\n<h2>#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<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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]\n   &amp;&amp; loops \u00d7 (rows + RRbF) &lt; (shared hit + shared read) \u00d7 8\n      -- \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\n   &amp;&amp; shared hit + shared read &gt; 64\n<\/code><\/pre>\n<p><\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>\n\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 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">CREATE TABLE tbl AS\nSELECT\n  generate_series(1, 100000) pk      -- 100K &quot;\u0444\u0430\u043a\u0442\u043e\u0432&quot;\n, (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\n, (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\n\nCREATE INDEX ON tbl(fk_org, fk_cli); -- \u0432\u0441\u0435 \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u043a \u0432 #2\n-- \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\n\nSELECT\n  *\nFROM\n  tbl\nWHERE\n  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\nLIMIT 20;<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/41d054891cdbbbe9af749c49d11bf95d.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/94c349925d23b1feaa0552155e0b74d2.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/p><\/blockquote>\n<p><\/p>\n<h2>#7: CTE \u00d7 CTE<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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\n   &amp;&amp; loops &gt; 10\n   &amp;&amp; loops \u00d7 (rows + RRbF) &gt; 10000\n      -- \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\n<\/code><\/pre>\n<p><\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>\n\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 <noindex><a rel=\"nofollow\" 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><\/noindex>? \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 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/p>\n<h2>#8: swap \u043d\u0430 \u0434\u0438\u0441\u043a (temp written)<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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; *\n   &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>\n\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 <noindex><a rel=\"nofollow\" href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/runtime-config-resource#GUC-WORK-MEM\">work_mem<\/a><\/noindex>, \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;\n-- &quot;16MB&quot;\n\nSELECT\n  random()\nFROM\n  generate_series(1, 1000000)\nORDER BY\n  1;<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/99ab19ab14c60fdf8651368c58bb0856.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/a9f3cd8b5133d52313aa213df7ca0381.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" 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><\/noindex><\/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>#9: \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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]\n   &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>\n\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 <noindex><a rel=\"nofollow\" 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><\/noindex>.<\/p><\/blockquote>\n<p><\/p>\n<h2>#10: \u00ab\u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a\u00bb<\/h2>\n<p><\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442<\/h4>\n<p>\n\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; *\n   &amp;&amp; (shared hit \/ 8K) + (shared read \/ 1K) &lt; time \/ 1000\n      -- RAM hit = 64MB\/s, HDD read = 8MB\/s\n   &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\n<\/code><\/pre>\n<p><\/p>\n<h4>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h4>\n<p>\n\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 <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/328920\/\">\u0442\u0443\u0442<\/a><\/noindex> \u0438 <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/329694\/\">\u0442\u0443\u0442<\/a><\/noindex>.<\/p>\n<p><img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/42acc454a0cc9a3d49ce459ab3da1db5.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<img decoding=\"async\" alt=\"\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\" src=\"\/wp-content\/uploads\/2020\/03\/d7f708f6c1e338ab5d4c71ce372df864.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/tensor\/blog\/492694\/\">habr.com<\/a> <\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u043c\u044b \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0438 explain.tensor.ru \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \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 \u043a PostgreSQL. \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 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438, \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: \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 \u0410 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":75689,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-75688","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u043c\u044b \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0438 explain.tensor.ru \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \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 \u043a PostgreSQL. \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 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438, \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: \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. :) \u0410\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/it\/blog\/administrirovanie\/reczepty-dlya-hvorayushhih-sql-zaprosov\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"it_IT\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\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 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u043c\u044b \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0438 explain.tensor.ru \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \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 \u043a PostgreSQL. \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 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438, \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: \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. :) \u0410\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/it\/blog\/administrirovanie\/reczepty-dlya-hvorayushhih-sql-zaprosov\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-03-27T17:42:35+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-03-27T17:42:35+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Ricette per query SQL malate | ProHoster","description":"Qualche mese fa abbiamo annunciato explain.tensor.ru \u2014 un servizio pubblico per l'analisi e la visualizzazione dei piani delle query per PostgreSQL. Nel frattempo, lo avete gi\u00e0 utilizzato oltre 6000 volte, ma una delle funzionalit\u00e0 utili potrebbe essere passata inosservata: si tratta dei suggerimenti strutturali, che appaiono pi\u00f9 o meno cos\u00ec: Ascoltateli e le vostre query \"diventeranno fluide e setose\". :) A","canonical_url":"https:\/\/prohoster.info\/it\/blog\/administrirovanie\/reczepty-dlya-hvorayushhih-sql-zaprosov","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"it_IT","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\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 | ProHoster","og:description":"\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u043c\u044b \u0430\u043d\u043e\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0438 explain.tensor.ru \u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \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 \u043a PostgreSQL. \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 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438, \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: \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. :) \u0410","og:url":"https:\/\/prohoster.info\/it\/blog\/administrirovanie\/reczepty-dlya-hvorayushhih-sql-zaprosov","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-03-27T17:42:35+00:00","article:modified_time":"2020-03-27T17:42:35+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"75688","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 17:51:28","updated":"2022-10-01 20:52:21"},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/posts\/75688","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/comments?post=75688"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/posts\/75688\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/media\/75689"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/media?parent=75688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/categories?post=75688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/it\/wp-json\/wp\/v2\/tags?post=75688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}