{"id":90779,"date":"2020-08-06T01:42:15","date_gmt":"2020-08-05T23:42:15","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/postgresql-antipatterns-dolzhen-ostatsya-tolko-odin"},"modified":"2020-08-06T01:42:15","modified_gmt":"2020-08-05T23:42:15","slug":"postgresql-antipatterns-dolzhen-ostatsya-tolko-odin","status":"publish","type":"post","link":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postgresql-antipatterns-dolzhen-ostatsya-tolko-odin","title":{"rendered":"Antipattern t\u00eb PostgreSQL: \u00abDuhet t\u00eb mbetet vet\u00ebm nj\u00eb!\u00bb","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>\u041d\u0430 SQL \u0432\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u00ab\u0447\u0442\u043e\u00bb \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0430 \u043d\u0435 \u00ab\u043a\u0430\u043a\u00bb \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0442\u0438\u043b\u0435 \u00ab\u043a\u0430\u043a \u0441\u043b\u044b\u0448\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u0438 \u043f\u0438\u0448\u0435\u0442\u0441\u044f\u00bb \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0432\u043e\u0435 \u043f\u043e\u0447\u0435\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/494776\/\">\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 SQL<\/a><\/noindex>. <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>GROUP\/DISTINCT<\/code> \u0438 <code>LIMIT<\/code> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>\u0412\u043e\u0442 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 <i>\u00ab\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0438 \u044d\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u043a\u0438\u043d\u044c \u0432\u0441\u0435 \u0434\u0443\u0431\u043b\u0438, <b>\u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d<\/b> \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443\u00bb<\/i> \u2014 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u0418 \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0435\u0437\u0435\u0442 \u0438 \u044d\u0442\u043e \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u00bb, \u0438\u043d\u043e\u0433\u0434\u0430 \u2014 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0435\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u044b.<\/p>\n<p><img decoding=\"async\" alt=\"PostgreSQL Antipatterns: &laquo;\u0414\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d!&raquo;\" src=\"\/wp-content\/uploads\/2020\/08\/4e49695a741529b631eaff36fe9f295b.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n\u041d\u0443, \u043c\u043e\u0436\u0435\u0442, \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0440\u0435\u043b\u0438\u0449\u043d\u044b\u0435, \u043d\u043e\u2026<\/p>\n<h2>\u00ab\u0421\u043b\u0430\u0434\u043a\u0430\u044f \u043f\u0430\u0440\u043e\u0447\u043a\u0430\u00bb: JOIN + DISTINCT<\/h2>\n<p><\/p>\n<pre><code class=\"sql\">SELECT DISTINCT\n  X.*\nFROM\n  X\nJOIN\n  Y\n    ON Y.fk = X.pk\nWHERE\n  Y.bool_condition;<\/code><\/pre>\n<p>\n\u041a\u0430\u043a \u0431\u044b \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u0438 <b>\u043e\u0442\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 X, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 Y \u0435\u0441\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u043c\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c<\/b>. \u041d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0447\u0435\u0440\u0435\u0437 <code>JOIN<\/code> \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f pk \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 (\u0440\u043e\u0432\u043d\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 Y \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c). \u041a\u0430\u043a \u0443\u0431\u0440\u0430\u0442\u044c? \u041a\u043e\u043d\u0435\u0447\u043d\u043e <code>DISTINCT<\/code>!<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\n\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u00ab\u0440\u0430\u0434\u0443\u0435\u0442\u00bb, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 X-\u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0435\u043d \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 Y-\u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0430 \u043f\u043e\u0442\u043e\u043c \u0433\u0435\u0440\u043e\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0434\u0443\u0431\u043b\u0438\u2026<\/p>\n<p><img decoding=\"async\" alt=\"PostgreSQL Antipatterns: &laquo;\u0414\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d!&raquo;\" src=\"\/wp-content\/uploads\/2020\/08\/7f993db0c8aa66cc5c9390f8f4b24d62.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n\u041a\u0430\u043a \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c? \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0441\u043e\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e <b>\u00ab\u043e\u0442\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 X, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 Y \u0435\u0441\u0442\u044c \u0425\u041e\u0422\u042f \u0411\u042b \u041e\u0414\u041d\u0410 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u043c\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c\u00bb<\/b> \u2014 \u0432\u0435\u0434\u044c \u0438\u0437 \u0441\u0430\u043c\u043e\u0439 Y-\u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<h4>\u0412\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 EXISTS<\/h4>\n<p><\/p>\n<pre><code class=\"sql\">SELECT\n  *\nFROM\n  X\nWHERE\n  EXISTS(\n    SELECT\n      NULL\n    FROM\n      Y\n    WHERE\n      fk = X.pk AND\n      bool_condition\n    LIMIT 1\n  );<\/code><\/pre>\n<p>\n\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 PostgreSQL \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442, \u0447\u0442\u043e \u0432 EXISTS \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0435\u0440\u0432\u0443\u044e \u043f\u043e\u043f\u0430\u0432\u0448\u0443\u044e\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c, \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0440\u044b\u0435 \u2014 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c <code>LIMIT 1<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>EXISTS<\/code>.<\/p>\n<h4>LATERAL JOIN<\/h4>\n<p><\/p>\n<pre><code class=\"sql\">SELECT\n  X.*\nFROM\n  X\n, LATERAL (\n    SELECT\n      Y.*\n    FROM\n      Y\n    WHERE\n      fk = X.pk AND\n      bool_condition\n    LIMIT 1\n  ) Y\nWHERE\n  Y IS DISTINCT FROM NULL;<\/code><\/pre>\n<p><\/p>\n<blockquote><p>\u042d\u0442\u043e\u0442 \u0436\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043d\u0430\u0448\u0435\u0434\u0448\u0435\u0439\u0441\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 Y-\u0437\u0430\u043f\u0438\u0441\u0438. \u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \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\/484670\/\">\u00abPostgreSQL Antipatterns: \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\u00bb<\/a><\/noindex>.<\/p><\/blockquote>\n<p><\/p>\n<h2>\u00ab\u0417\u0430\u0447\u0435\u043c \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435\u00bb: DISTINCT [ON] + LIMIT 1<\/h2>\n<p>\n\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430\/\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u0438\u0445, \u043a\u0430\u043a \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<\/p>\n<pre><code class=\"sql\">SELECT DISTINCT ON(X.pk)\n  *\nFROM\n  X\nJOIN\n  Y\n    ON Y.fk = X.pk\nLIMIT 1;<\/code><\/pre>\n<p>\n\u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0438\u0442\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0421\u0423\u0411\u0414:<\/p>\n<ul>\n<li>\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438<\/li>\n<li>\u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u043e X.pk<\/li>\n<li>\u0438\u0437 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043e\u0434\u043d\u0443<\/li>\n<\/ul>\n<p>\n\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0447\u0442\u043e? <b>\u00ab\u041a\u0430\u043a\u0443\u044e-\u0442\u043e \u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0438\u0441\u044c\u00bb<\/b> \u0438\u0437 \u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u2014 \u0430 \u0435\u0441\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u044d\u0442\u0443 \u043e\u0434\u043d\u0443 \u0438\u0437 \u043d\u0435\u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0437\u0432\u0435 \u043a\u0430\u043a-\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f?.. \u00ab\u0410 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u0437\u0430\u0447\u0435\u043c \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435?\u00bb<\/p>\n<pre><code class=\"sql\">SELECT\n  *\nFROM\n  (\n    SELECT\n      *\n    FROM\n      X\n    -- \u0441\u044e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0443\u043d\u0443\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439\n    LIMIT 1 -- +1 Limit\n  ) X\nJOIN\n  Y\n    ON Y.fk = X.pk\nLIMIT 1;\n<\/code><\/pre>\n<p>\n\u0418 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u0442\u0435\u043c\u0430 \u0441 <code>GROUP BY + LIMIT 1<\/code>.<\/p>\n<h2>\u00ab\u041c\u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c\u00bb: \u043d\u0435\u044f\u0432\u043d\u044b\u0439 GROUP + LIMIT<\/h2>\n<p>\n\u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 <b>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u0445 \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u0442\u044b<\/b> \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438 \u0438\u043b\u0438 CTE \u043f\u043e \u0445\u043e\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"sql\">...\nCASE\n  WHEN (\n    SELECT\n      count(*)\n    FROM\n      X\n    LIMIT 1\n  ) = 0 THEN ...<\/code><\/pre>\n<p>\n\u0410\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (<code>count\/min\/max\/sum\/...<\/code>) \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435, \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u044f\u0432\u043d\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f <code>GROUP BY<\/code>. \u0422\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0442 \u0441 <code>LIMIT<\/code> \u043e\u043d\u0438 \u0434\u0440\u0443\u0436\u0430\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c.<\/p>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0434\u0443\u043c\u0430\u0442\u044c <i>\u00ab\u0432\u043e\u0442 \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u0435\u0441\u0442\u044c, \u0442\u043e \u043c\u043d\u0435 \u043d\u0430\u0434\u043e \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 LIMIT\u00bb<\/i>. \u041d\u043e \u043d\u0435 \u043d\u0430\u0434\u043e \u0442\u0430\u043a! \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u0430\u0437\u044b \u044d\u0442\u043e:<\/p>\n<ul>\n<li>\u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0439, \u0447\u0442\u043e \u0445\u043e\u0442\u044f\u0442 <b>\u043f\u043e \u0432\u0441\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044f\u043c<\/b><\/li>\n<li>\u043e\u0442\u0434\u0430\u0439 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u044f\u0442<\/li>\n<\/ul>\n<p>\n\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0442\u0443\u0442 \u0443\u043c\u0435\u0441\u0442\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 \u0437\u0430\u043c\u0435\u043d:<\/p>\n<ul>\n<li><code>(count + LIMIT 1) = 0<\/code> <b>\u043d\u0430<\/b> <code>NOT EXISTS(LIMIT 1)<\/code><\/li>\n<li><code>(count + LIMIT 1) &gt; 0<\/code> <b>\u043d\u0430<\/b> <code>EXISTS(LIMIT 1)<\/code><\/li>\n<li><code>count &gt;= N<\/code> <b>\u043d\u0430<\/b> <code>(SELECT count(*) FROM (... LIMIT N))<\/code><\/li>\n<\/ul>\n<p><\/p>\n<h2>\u00ab\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0448\u0430\u0442\u044c \u0432 \u0433\u0440\u0430\u043c\u043c\u0430\u0445\u00bb: DISTINCT + LIMIT<\/h2>\n<p><\/p>\n<pre><code class=\"sql\">SELECT DISTINCT\n  pk\nFROM\n  X\nLIMIT $1<\/code><\/pre>\n<p>\n\u041d\u0430\u0438\u0432\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f, <i>\u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043d\u0430\u0439\u0434\u0435\u043c $1 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/i>.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430-\u0442\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043a \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u043e\u0432\u043e\u043c\u0443 \u0443\u0437\u043b\u0443 <b>Index Skip Scan<\/b>, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u043f\u043e\u043a\u0430 \u2014 \u043d\u0435\u0442.<\/p>\n<p>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 <b>\u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u044b \u0432\u0441\u0435-\u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438<\/b>, \u0443\u043d\u0438\u043a\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0436\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0433\u0440\u0443\u0441\u0442\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 <b>$1 = 4<\/b>, \u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u2014 \u0441\u043e\u0442\u043d\u0438 \u0442\u044b\u0441\u044f\u0447\u2026<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0433\u0440\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u043f\u0443\u0441\u0442\u0443, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c <noindex><a rel=\"nofollow\" href=\"https:\/\/wiki.postgresql.org\/wiki\/Loose_indexscan\">\u00abDISTINCT \u0434\u043b\u044f \u0431\u0435\u0434\u043d\u044b\u0445\u00bb \u0438\u0437 PostgreSQL Wiki<\/a><\/noindex>:<\/p>\n<p><img decoding=\"async\" alt=\"PostgreSQL Antipatterns: &laquo;\u0414\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d!&raquo;\" src=\"\/wp-content\/uploads\/2020\/08\/61f17635a732a88d7803cda52018a925.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\/513324\/\">habr.com<\/a> <\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041d\u0430 SQL \u0432\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u00ab\u0447\u0442\u043e\u00bb \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0430 \u043d\u0435 \u00ab\u043a\u0430\u043a\u00bb \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0442\u0438\u043b\u0435 \u00ab\u043a\u0430\u043a \u0441\u043b\u044b\u0448\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u0438 \u043f\u0438\u0448\u0435\u0442\u0441\u044f\u00bb \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0432\u043e\u0435 \u043f\u043e\u0447\u0435\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 SQL. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f GROUP\/DISTINCT \u0438 LIMIT \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438. [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":90780,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-90779","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\u0430 SQL \u0432\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u00ab\u0447\u0442\u043e\u00bb \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0430 \u043d\u0435 \u00ab\u043a\u0430\u043a\u00bb \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0442\u0438\u043b\u0435 \u00ab\u043a\u0430\u043a \u0441\u043b\u044b\u0448\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u0438 \u043f\u0438\u0448\u0435\u0442\u0441\u044f\u00bb \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0432\u043e\u0435 \u043f\u043e\u0447\u0435\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 SQL. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f GROUP\/DISTINCT \u0438 LIMIT \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438.\" \/>\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-dolzhen-ostatsya-tolko-odin\" \/>\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: \u00ab\u0414\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d!\u00bb | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041d\u0430 SQL \u0432\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u00ab\u0447\u0442\u043e\u00bb \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0430 \u043d\u0435 \u00ab\u043a\u0430\u043a\u00bb \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0442\u0438\u043b\u0435 \u00ab\u043a\u0430\u043a \u0441\u043b\u044b\u0448\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u0438 \u043f\u0438\u0448\u0435\u0442\u0441\u044f\u00bb \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0432\u043e\u0435 \u043f\u043e\u0447\u0435\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 SQL. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f GROUP\/DISTINCT \u0438 LIMIT \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postgresql-antipatterns-dolzhen-ostatsya-tolko-odin\" \/>\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-08-05T23:42:15+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-08-05T23:42:15+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\udd47Antipatterns n\u00eb PostgreSQL: \"Duhet t\u00eb mbetet vet\u00ebm nj\u00eb!\" | ProHoster","description":"N\u00eb SQL p\u00ebrshkruani \"\u00e7far\u00eb\" doni t\u00eb merrni, jo \"si\" duhet t\u00eb ekzekutohet. Prandaj, problemi i zhvillimit t\u00eb k\u00ebrkesave SQL n\u00eb stilin \"si d\u00ebgjohet, ashtu edhe shkruhet\" z\u00eb vendin e tij t\u00eb nderuar, krahas ve\u00e7orive t\u00eb llogaritjes s\u00eb kushteve n\u00eb SQL. Sot, n\u00ebp\u00ebrmjet shembujve shum\u00eb t\u00eb thjesht\u00eb, do t\u00eb shohim se \u00e7far\u00eb mund t\u00eb ndodhi n\u00eb kontekstin e p\u00ebrdorimit t\u00eb GROUP\/DISTINCT dhe LIMIT s\u00eb bashku me to.","canonical_url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postgresql-antipatterns-dolzhen-ostatsya-tolko-odin","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: \u00ab\u0414\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d!\u00bb | ProHoster","og:description":"\u041d\u0430 SQL \u0432\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u00ab\u0447\u0442\u043e\u00bb \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0430 \u043d\u0435 \u00ab\u043a\u0430\u043a\u00bb \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0442\u0438\u043b\u0435 \u00ab\u043a\u0430\u043a \u0441\u043b\u044b\u0448\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u0438 \u043f\u0438\u0448\u0435\u0442\u0441\u044f\u00bb \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0432\u043e\u0435 \u043f\u043e\u0447\u0435\u0442\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 SQL. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f GROUP\/DISTINCT \u0438 LIMIT \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438.","og:url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/postgresql-antipatterns-dolzhen-ostatsya-tolko-odin","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-08-05T23:42:15+00:00","article:modified_time":"2020-08-05T23:42:15+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"90779","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 12:42:25","updated":"2022-10-02 04:56:20"},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/90779","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=90779"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/90779\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media\/90780"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media?parent=90779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/categories?post=90779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/tags?post=90779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}