{"id":55780,"date":"2020-01-28T00:00:00","date_gmt":"2020-01-27T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/postgresql-antipatterns-udarim-slovarem-po-tyazhelomu-join"},"modified":"2020-02-18T14:03:56","modified_gmt":"2020-02-18T11:03:56","slug":"postgresql-antipatterns-udarim-slovarem-po-tyazhelomu-join","status":"publish","type":"post","link":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postgresql-antipatterns-udarim-slovarem-po-tyazhelomu-join","title":{"rendered":"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","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0430\u043b\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u00ab\u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0445\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 PostgreSQL:<\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/post\/484670\/\">\u0440\u0435\u0434\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043b\u0435\u0442\u0438\u0442 \u0434\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b JOIN<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/post\/479920\/\">\u0441\u0438\u0437\u0438\u0444\u043e\u0432 JOIN \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/post\/479508\/\">\u0432\u0440\u0435\u0434\u043d\u044b\u0435 JOIN \u0438 OR<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/post\/479298\/\">CTE JOIN CTE<\/a><\/noindex><\/li>\n<\/ul>\n<p>\n\u041d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044f \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043b\u044e\u0431\u043b\u044e JOIN\u2026 \ud83d\ude42<\/p>\n<p>\u041d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u0441 \u043d\u0438\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 <b>\u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0435\u043c\u043a\u043e\u0433\u043e JOIN<\/b> \u2014 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u043e\u0432\u0430\u0440\u044f.<\/p>\n<p><img decoding=\"async\" alt=\"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\" src=\"\/wp-content\/uploads\/2020\/01\/3e6f72241e114acf371fd667b4f727b5.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<blockquote><p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 PostgreSQL 12 \u0447\u0430\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0438\u0436\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0447\u0443\u0442\u044c \u0438\u043d\u0430\u0447\u0435 \u0438\u0437-\u0437\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/www.depesz.com\/2019\/02\/19\/waiting-for-postgresql-12-allow-user-control-of-cte-materialization-and-change-the-default-behavior\/\" rel=\"nofollow\">\u043d\u0435-\u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 CTE \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/a><\/noindex>. \u042d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043e \u043a \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 <code>MATERIALIZED<\/code>.<\/p><\/blockquote>\n<p><\/p>\n<h2>\u041c\u043d\u043e\u0433\u043e \u00ab\u0444\u0430\u043a\u0442\u043e\u0432\u00bb \u043f\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0430\u0440\u044e<\/h2>\n<p>\n\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u043d\u0430\u0434\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u043f\u0438\u0441\u043e\u043a <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/483176\/\">\u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/a><\/noindex> \u0438\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f\u043c\u0438:<\/p>\n<pre><code class=\"plaintext\">25.01 | \u0418\u0432\u0430\u043d\u043e\u0432 \u0418.\u0418. | \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.\n22.01 | \u0418\u0432\u0430\u043d\u043e\u0432 \u0418.\u0418. | \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u043d\u0430 \u0425\u0430\u0431\u0440: \u0436\u0438\u0437\u043d\u044c \u0431\u0435\u0437 JOIN.\n20.01 | \u041f\u0435\u0442\u0440\u043e\u0432 \u041f.\u041f. | \u041f\u043e\u043c\u043e\u0447\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441.\n18.01 | \u0418\u0432\u0430\u043d\u043e\u0432 \u0418.\u0418. | \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u043d\u0430 \u0425\u0430\u0431\u0440: JOIN \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.\n16.01 | \u041f\u0435\u0442\u0440\u043e\u0432 \u041f.\u041f. | \u041f\u043e\u043c\u043e\u0447\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441.\n<\/code><\/pre>\n<p>\n\u0412 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0430\u0432\u0442\u043e\u0440\u044b \u0437\u0430\u0434\u0430\u0447 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0431\u044b \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043d\u0430\u0448\u0435\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <b><i>\u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043b\u044e\u0434\u0435\u0439<\/i><\/b> \u2014 \u00ab\u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u0441\u0442\u0432\u0430\u00bb \u0432\u0432\u0435\u0440\u0445 \u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0438\u043b\u0438 \u00ab\u043e\u0442 \u0441\u043c\u0435\u0436\u043d\u0438\u043a\u043e\u0432\u00bb \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u043e\u0432 (\u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438, \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u044b, \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433, &#8230;).<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043c, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 1000 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0442\u043e\u043b\u044c\u043a\u043e 20 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 (\u043e\u0431\u044b\u0447\u043d\u043e \u0434\u0430\u0436\u0435 \u043c\u0435\u043d\u044c\u0448\u0435) \u0441\u0442\u0430\u0432\u044f\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0430\u0434\u0440\u0435\u0441 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f \u0438 <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/484670\/\">\u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u0442\u0438\u043c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u044b\u043c \u0437\u043d\u0430\u043d\u0438\u0435\u043c<\/a><\/noindex>, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u00ab\u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0439\u00bb \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p><b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043f\u0442-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/b><\/p>\n<pre><code class=\"sql\">-- \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438\nCREATE TABLE person AS\nSELECT\n  id\n, repeat(chr(ascii('a') + (id % 26)), (id % 32) + 1) &quot;name&quot;\n, '2000-01-01'::date - (random() * 1e4)::integer birth_date\nFROM\n  generate_series(1, 1000) id;\n\nALTER TABLE person ADD PRIMARY KEY(id);\n\n-- \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c\nCREATE TABLE task AS\nWITH aid AS (\n  SELECT\n    id\n  , array_agg((random() * 999)::integer + 1) aids\n  FROM\n    generate_series(1, 1000) id\n  , generate_series(1, 20)\n  GROUP BY\n    1\n)\nSELECT\n  *\nFROM\n  (\n    SELECT\n      id\n    , '2020-01-01'::date - (random() * 1e3)::integer task_date\n    , (random() * 999)::integer + 1 owner_id\n    FROM\n      generate_series(1, 100000) id\n  ) T\n, LATERAL(\n    SELECT\n      aids[(random() * (array_length(aids, 1) - 1))::integer + 1] author_id\n    FROM\n      aid\n    WHERE\n      id = T.owner_id\n    LIMIT 1\n  ) a;\n\nALTER TABLE task ADD PRIMARY KEY(id);\nCREATE INDEX ON task(owner_id, task_date);\nCREATE INDEX ON task(author_id);\n<\/code><\/pre>\n<p>\n\u041f\u043e\u043a\u0430\u0436\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 100 \u0437\u0430\u0434\u0430\u0447 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f:<\/p>\n<pre><code class=\"sql\">SELECT\n  task.*\n, person.name\nFROM\n  task\nLEFT JOIN\n  person\n    ON person.id = task.author_id\nWHERE\n  owner_id = 777\nORDER BY\n  task_date DESC\nLIMIT 100;<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"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\" src=\"\/wp-content\/uploads\/2020\/01\/0f4d8f773cc8f695b495ce627f365122.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" href=\"https:\/\/explain.tensor.ru\/archive\/explain\/5f4f9c25197bf7c534ffe7a25b1b75a6:0:2020-01-27\" rel=\"nofollow\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/noindex><\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e <b>1\/3 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 3\/4 \u0447\u0442\u0435\u043d\u0438\u0439<\/b> \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044b\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b 100 \u0440\u0430\u0437 \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0430 \u2014 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u043e \u043c\u044b \u0436\u0435 \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0441\u0440\u0435\u0434\u0438 \u044d\u0442\u043e\u0439 \u0441\u043e\u0442\u043d\u0438 <b>\u0432\u0441\u0435\u0433\u043e 20 \u0440\u0430\u0437\u043d\u044b\u0445<\/b> \u2014 \u043d\u0435\u043b\u044c\u0437\u044f \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u043d\u0430\u043d\u0438\u0435?<\/p>\n<h2>hstore-\u0441\u043b\u043e\u0432\u0430\u0440\u044c<\/h2>\n<p>\n\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <noindex><a rel=\"nofollow\" href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/hstore\" rel=\"nofollow\">\u0442\u0438\u043f\u043e\u043c hstore<\/a><\/noindex> \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u00ab\u0441\u043b\u043e\u0432\u0430\u0440\u044f\u00bb \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"sql\">CREATE EXTENSION hstore<\/code><\/pre>\n<p>\n\u0412 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c ID \u0430\u0432\u0442\u043e\u0440\u0430 \u0438 \u0435\u0433\u043e \u0438\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443:<\/p>\n<pre><code class=\"sql\">-- \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443\nWITH T AS (\n  SELECT\n    *\n  FROM\n    task\n  WHERE\n    owner_id = 777\n  ORDER BY\n    task_date DESC\n  LIMIT 100\n)\n-- \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0434\u043b\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439\n, dict AS (\n  SELECT\n    hstore( -- hstore(keys::text[], values::text[])\n      array_agg(id)::text[]\n    , array_agg(name)::text[]\n    )\n  FROM\n    person\n  WHERE\n    id = ANY(ARRAY(\n      SELECT DISTINCT\n        author_id\n      FROM\n        T\n    ))\n)\n-- \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044f\nSELECT\n  *\n, (TABLE dict) -&gt; author_id::text -- hstore -&gt; key\nFROM\n  T;<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"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\" src=\"\/wp-content\/uploads\/2020\/01\/3ab866aed87c077f45d789944a217cd0.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<noindex><a rel=\"nofollow\" href=\"https:\/\/explain.tensor.ru\/archive\/explain\/6ee4e4e26ded9567ac9631ceee9bb8c0:0:2020-01-27\" rel=\"nofollow\">[\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 explain.tensor.ru]<\/a><\/noindex><\/p>\n<p>\u041d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0445 \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043e <b>\u0432 2 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0432 7 \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0445<\/b>! \u041f\u043e\u043c\u0438\u043c\u043e \u00ab\u043e\u0441\u043b\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u043d\u0438\u044f\u00bb, \u044d\u0442\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u043b\u043e \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0435\u0449\u0435 \u0438 <b>\u043c\u0430\u0441\u0441\u043e\u0432\u043e\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/b> \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>= ANY(ARRAY(...))<\/code>.<\/p>\n<h4>\u0417\u0430\u043f\u0438\u0441\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b: \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>\n\u041d\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u043d\u0435 \u043e\u0434\u043d\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435, \u0430 \u0446\u0435\u043b\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c? \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c PostgreSQL <b>\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0430\u043a \u0441 \u0435\u0434\u0438\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c<\/b>:<\/p>\n<pre><code class=\"sql\">...\n, dict AS (\n  SELECT\n    hstore(\n      array_agg(id)::text[]\n    , array_agg(p)::text[] -- \u043c\u0430\u0433\u0438\u044f #1\n    )\n  FROM\n    person p\n  WHERE\n    ...\n)\nSELECT\n  *\n, (((TABLE dict) -&gt; author_id::text)::person).* -- \u043c\u0430\u0433\u0438\u044f #2\nFROM\n  T;<\/code><\/pre>\n<p>\n\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u0447\u0442\u043e \u0442\u0443\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e:<\/p>\n<ol>\n<li>\u041c\u044b \u0432\u0437\u044f\u043b\u0438 <b>p \u043a\u0430\u043a \u0430\u043b\u0438\u0430\u0441 \u043a \u043f\u043e\u043b\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b person<\/b> \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0438\u0437 \u043d\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432.<\/li>\n<li>\u042d\u0442\u043e\u0442 <b>\u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043f\u0435\u0440\u0435\u043a\u0430\u0441\u0442\u043e\u0432\u0430\u043b\u0438<\/b> \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u043e\u043a (person[]::text[]), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u0432 hstore-\u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/li>\n<li>\u041f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u044b \u0435\u0435 <b>\u0432\u044b\u0442\u0430\u0449\u0438\u043b\u0438 \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443<\/b> \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/li>\n<li>\u0422\u0435\u043a\u0441\u0442 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e <b>\u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/b> person (\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u0439 \u0435\u0439 \u0442\u0438\u043f).<\/li>\n<li>\u00ab\u0420\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0438\u00bb \u0442\u0438\u043f\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>(...).*<\/code>.<\/li>\n<\/ol>\n<p><\/p>\n<h2>json-\u0441\u043b\u043e\u0432\u0430\u0440\u044c<\/h2>\n<p>\n\u041d\u043e \u0442\u0430\u043a\u043e\u0439 \u0444\u043e\u043a\u0443\u0441, \u043a\u0430\u043a \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0432\u044b\u0448\u0435, \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u00ab\u0440\u0430\u0441\u043a\u0430\u0441\u0442\u043e\u0432\u043a\u0443\u00bb. \u0420\u043e\u0432\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442, \u0438 \u0435\u0441\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>\u0441\u0442\u0440\u043e\u043a\u0443 CTE, \u0430 \u043d\u0435 \u00ab\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439\u00bb \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/b>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u0443\u0442 <noindex><a rel=\"nofollow\" href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/functions-json\" rel=\"nofollow\">\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 json<\/a><\/noindex>:<\/p>\n<pre><code class=\"sql\">...\n, p AS ( -- \u044d\u0442\u043e \u0443\u0436\u0435 CTE\n  SELECT\n    *\n  FROM\n    person\n  WHERE\n    ...\n)\n, dict AS (\n  SELECT\n    json_object( -- \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u0443\u0436\u0435 json\n      array_agg(id)::text[]\n    , array_agg(row_to_json(p))::text[] -- \u0438 \u0432\u043d\u0443\u0442\u0440\u0438 json \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438\n    )\n  FROM\n    p\n)\nSELECT\n  *\nFROM\n  T\n, LATERAL(\n    SELECT\n      *\n    FROM\n      json_to_record(\n        ((TABLE dict) -&gt;&gt; author_id::text)::json -- \u0438\u0437\u0432\u043b\u0435\u043a\u043b\u0438 \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043a\u0430\u043a json\n      ) AS j(name text, birth_date date) -- \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443\n  ) j;<\/code><\/pre>\n<p>\n\u041d\u0430\u0434\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043d\u0435 \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u00ab\u0440\u043e\u0434\u043d\u0430\u044f\u00bb \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>json_populate_record<\/code>.<\/p>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043b\u043e\u0432\u0430\u0440\u044e \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e, \u043d\u043e <b>\u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438 \u043d\u0430 json-[\u0434\u0435]\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0435\u043b\u0438\u043a\u0438<\/b>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u00ab\u0447\u0435\u0441\u0442\u043d\u044b\u0439\u00bb CTE Scan \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u044f \u0445\u0443\u0436\u0435.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\n\u0418\u0442\u0430\u043a, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u2014 <b>hstore \/ json_object<\/b>. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0441\u0430\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u0436\u0435 \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u0441 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u0438\u043b\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a \u0442\u0435\u043a\u0441\u0442\u0443: <b>array_agg(i::text) \/ array_agg(i)::text[]<\/b>.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0438\u0434\u043e\u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0443\u0433\u0443\u0431\u043e \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u2014 <b>\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0440\u0430\u0437\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u044e\u0447\u0435\u0439<\/b>:<\/p>\n<pre><code class=\"sql\">WITH dict AS (\n  SELECT\n    hstore(\n      array_agg(i::text)\n    , array_agg(i::text)\n    )\n  FROM\n    generate_series(1, ...) i\n)\nTABLE dict;<\/code><\/pre>\n<p>\n<b class=\"spoiler_title\">\u041e\u0446\u0435\u043d\u043e\u0447\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 : \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/p>\n<pre><code class=\"sql\">WITH T AS (\n  SELECT\n    *\n  , (\n      SELECT\n        regexp_replace(ea[array_length(ea, 1)], '^Execution Time: (d+.d+) ms$', '1')::real et\n      FROM\n        (\n          SELECT\n            array_agg(el) ea\n          FROM\n            dblink('port= ' || current_setting('port') || ' dbname=' || current_database(), $$\n              explain analyze\n              WITH dict AS (\n                SELECT\n                  hstore(\n                    array_agg(i::text)\n                  , array_agg(i::text)\n                  )\n                FROM\n                  generate_series(1, $$ || (1 &lt;&lt; v) || $$) i\n              )\n              TABLE dict\n            $$) T(el text)\n        ) T\n    ) et\n  FROM\n    generate_series(0, 19) v\n  ,   LATERAL generate_series(1, 7) i\n  ORDER BY\n    1, 2\n)\nSELECT\n  v\n, avg(et)::numeric(32,3)\nFROM\n  T\nGROUP BY\n  1\nORDER BY\n  1;<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"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\" src=\"\/wp-content\/uploads\/2020\/01\/f822275ca24790e0267c1f5b08174d84.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n\u041d\u0430 PostgreSQL 11 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0434\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0432 2^12 \u043a\u043b\u044e\u0447\u0435\u0439 <b>\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 json \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/b>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f json_object \u0438 \u00ab\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e\u00bb \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 <code>array_agg(i::text)<\/code>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u043f\u043e 8 \u0440\u0430\u0437 \u2014 \u0432\u0435\u0434\u044c \u0435\u0441\u043b\u0438 \u043a \u0441\u043b\u043e\u0432\u0430\u0440\u044e \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f, \u0442\u043e \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u043d\u0443\u0436\u0435\u043d?<\/p>\n<p><b class=\"spoiler_title\">\u041e\u0446\u0435\u043d\u043e\u0447\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 : \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f<\/b><\/p>\n<pre><code class=\"sql\">WITH T AS (\n  SELECT\n    *\n  , (\n      SELECT\n        regexp_replace(ea[array_length(ea, 1)], '^Execution Time: (d+.d+) ms$', '1')::real et\n      FROM\n        (\n          SELECT\n            array_agg(el) ea\n          FROM\n            dblink('port= ' || current_setting('port') || ' dbname=' || current_database(), $$\n              explain analyze\n              WITH dict AS (\n                SELECT\n                  json_object(\n                    array_agg(i::text)\n                  , array_agg(i::text)\n                  )\n                FROM\n                  generate_series(1, $$ || (1 &lt;&lt; v) || $$) i\n              )\n              SELECT\n                (TABLE dict) -&gt; (i % ($$ || (1 &lt;&lt; v) || $$) + 1)::text\n              FROM\n                generate_series(1, $$ || (1 &lt;&lt; (v + 3)) || $$) i\n            $$) T(el text)\n        ) T\n    ) et\n  FROM\n    generate_series(0, 19) v\n  , LATERAL generate_series(1, 7) i\n  ORDER BY\n    1, 2\n)\nSELECT\n  v\n, avg(et)::numeric(32,3)\nFROM\n  T\nGROUP BY\n  1\nORDER BY\n  1;<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"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\" src=\"\/wp-content\/uploads\/2020\/01\/d405671bd796604be37385417921695e.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n\u0418\u2026 \u0443\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e <b>\u043f\u0440\u0438 2^6 \u043a\u043b\u044e\u0447\u0435\u0439 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 json-\u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043a\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u044c<\/b> \u0447\u0442\u0435\u043d\u0438\u044e \u0438\u0437 hstore, \u0434\u043b\u044f jsonb \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 2^9.<\/p>\n<blockquote><p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044b:<\/p>\n<ul>\n<li>\u0435\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c <b>JOIN \u0441 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438<\/b> \u2014 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u00ab\u043e\u0441\u043b\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u043d\u0438\u0435\u00bb \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0432\u0430\u0448 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e <b>\u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u0432\u044b \u0438\u0437 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e<\/b> \u2014 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c json[b]<\/li>\n<li>\u0432\u043e \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 <b>hstore + array_agg(i::text)<\/b> \u0431\u0443\u0434\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435<\/li>\n<\/ul>\n<\/blockquote>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/485398\/\">habr.com<\/a><\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0430\u043b\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u00ab\u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0445\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 PostgreSQL: \u0440\u0435\u0434\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043b\u0435\u0442\u0438\u0442 \u0434\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b JOIN \u0441\u0438\u0437\u0438\u0444\u043e\u0432 JOIN \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432\u0440\u0435\u0434\u043d\u044b\u0435 JOIN \u0438 OR CTE JOIN CTE \u041d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044f \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043b\u044e\u0431\u043b\u044e JOIN\u2026 \ud83d\ude42 \u041d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u0441 \u043d\u0438\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-55780","post","type-post","status-publish","format-standard","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=\"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0430\u043b\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u00ab\u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0445\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 PostgreSQL: \u0440\u0435\u0434\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043b\u0435\u0442\u0438\u0442 \u0434\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b JOIN \u0441\u0438\u0437\u0438\u0444\u043e\u0432 JOIN \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432\u0440\u0435\u0434\u043d\u044b\u0435 JOIN \u0438 OR CTE JOIN CTE \u041d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044f \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043b\u044e\u0431\u043b\u044e JOIN\u2026 :) \u041d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u0441 \u043d\u0438\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c\" \/>\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\/sq\/blog\/administrirovanie\/postgresql-antipatterns-udarim-slovarem-po-tyazhelomu-join\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"sq_AL\" \/>\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\udd47PostgreSQL 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 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0430\u043b\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u00ab\u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0445\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 PostgreSQL: \u0440\u0435\u0434\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043b\u0435\u0442\u0438\u0442 \u0434\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b JOIN \u0441\u0438\u0437\u0438\u0444\u043e\u0432 JOIN \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432\u0440\u0435\u0434\u043d\u044b\u0435 JOIN \u0438 OR CTE JOIN CTE \u041d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044f \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043b\u044e\u0431\u043b\u044e JOIN\u2026 :) \u041d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u0441 \u043d\u0438\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postgresql-antipatterns-udarim-slovarem-po-tyazhelomu-join\" \/>\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-01-27T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:03:56+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\udd47PostgreSQL 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 | ProHoster","description":"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0430\u043b\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u00ab\u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0445\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 PostgreSQL: \u0440\u0435\u0434\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043b\u0435\u0442\u0438\u0442 \u0434\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b JOIN \u0441\u0438\u0437\u0438\u0444\u043e\u0432 JOIN \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432\u0440\u0435\u0434\u043d\u044b\u0435 JOIN \u0438 OR CTE JOIN CTE \u041d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044f \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043b\u044e\u0431\u043b\u044e JOIN\u2026 :) \u041d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u0441 \u043d\u0438\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c","canonical_url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postgresql-antipatterns-udarim-slovarem-po-tyazhelomu-join","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"sq_AL","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\udd47PostgreSQL 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 | ProHoster","og:description":"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0430\u043b\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u00ab\u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u0445\u00bb \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 PostgreSQL: \u0440\u0435\u0434\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043b\u0435\u0442\u0438\u0442 \u0434\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b JOIN \u0441\u0438\u0437\u0438\u0444\u043e\u0432 JOIN \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432\u0440\u0435\u0434\u043d\u044b\u0435 JOIN \u0438 OR CTE JOIN CTE \u041d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044f \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043b\u044e\u0431\u043b\u044e JOIN\u2026 :) \u041d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u0441 \u043d\u0438\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c","og:url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postgresql-antipatterns-udarim-slovarem-po-tyazhelomu-join","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-01-27T21:00:00+00:00","article:modified_time":"2020-02-18T11:03:56+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"55780","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 19:36:31","updated":"2022-10-03 09:27:23"},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/55780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/comments?post=55780"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/55780\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media?parent=55780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/categories?post=55780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/tags?post=55780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}