Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mvtq8-0007VR-3K for pgsql-admin@arkaria.postgresql.org; Sat, 11 Dec 2021 04:18:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mvtq6-0007EC-Pu for pgsql-admin@arkaria.postgresql.org; Sat, 11 Dec 2021 04:18:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mvtq6-0007E2-Fe for pgsql-admin@lists.postgresql.org; Sat, 11 Dec 2021 04:18:26 +0000 Received: from impout007aa.msg.chrl.nc.charter.net ([47.43.20.31] helo=impout007.msg.chrl.nc.charter.net) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mvtpz-0002wp-V2 for pgsql-admin@postgresql.org; Sat, 11 Dec 2021 04:18:25 +0000 Received: from cerberus.crazybean.net ([71.11.29.254]) by cmsmtp with ESMTP id vtpymjWkPhBsjvtpymFQQo; Sat, 11 Dec 2021 04:18:18 +0000 Authentication-Results: crazybean.net; none X-Authority-Analysis: v=2.4 cv=BISgEXcG c=1 sm=1 tr=0 ts=61b4268a a=GkUsAQdcAzAk0MT19QAIRQ==:117 a=GkUsAQdcAzAk0MT19QAIRQ==:17 a=xqWC_Br6kY4A:10 a=IOMw9HtfNCkA:10 a=pGLkceISAAAA:8 a=DOxZ6I4ch-azDpbUzcMA:9 a=QEXdDO2ut3YA:10 a=A8qHrOjyU3pE4J8l:21 a=_W_S_7VecoQA:10 Received: from smtpclient.apple ( [2001:470:e117:4:4dbf:8ebe:940d:30b4]) by cerberus.crazybean.net (OpenSMTPD) with ESMTPSA id 7c981428 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Fri, 10 Dec 2021 23:18:17 -0500 (EST) From: Rui DeSousa Message-Id: <351E9FBA-1FF4-4A7B-BD78-ED60F36BA7F7@crazybean.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_CEDA971B-2685-4B27-B54F-E132E8A8C237" Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.20.0.1.32\)) Subject: Re: Very slow 101-feeling design/query.. Date: Fri, 10 Dec 2021 23:18:14 -0500 In-Reply-To: Cc: pgsql-admin To: Wells Oliver References: X-Mailer: Apple Mail (2.3693.20.0.1.32) X-CMAE-Envelope: MS4xfNvI8TaGDWbqA1PpK3i9PtbnjEKL5BuxQ0zFUrYtQgwy3VsxJbcKcmKnMq+5hGDUKX/f6Q6zGmuWe5SwCOaEj9V6PjF8Unlhx1mWo2CH0JkacOSKjZhk 3r0w+rLfhQLz8NoT3cKduJCsGrTdJOyRnrOwCbC6zHlcudvQXs9kNcqgQXrT+eiksXuVWCVayXE7OxW26CNlAhhtafxFOZNCDSs+dhKkpqHAKECUsJLNiqAp l/idCAGWPDi9vUYqezVJRg== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_CEDA971B-2685-4B27-B54F-E132E8A8C237 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Dec 10, 2021, at 5:53 PM, Wells Oliver = wrote: >=20 > SELECT DISTINCT game_id FROM vw_joints Seeing distinct makes me cringe; most uses of it foreshadow either a = poor design or a bad query; not always but more often than not. If you=E2=80=99re really trying to do a distinct you can select from the = game table and do an exists against plays and joints tables thus = removing the distinct clause; but I digress as the given query is most = likely an over simplified query just as example. Partitioning does nothing here as the query doesn=E2=80=99t filter on = the partitioned field thus no partition elimination. --Apple-Mail=_CEDA971B-2685-4B27-B54F-E132E8A8C237 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Dec 10, 2021, at 5:53 PM, = Wells Oliver <wells.oliver@gmail.com> wrote:

SELECT DISTINCT game_id FROM = vw_joints

Seeing distinct = makes me cringe; most uses of it foreshadow either a poor design or a = bad query; not always but more often than not.

If you=E2=80=99re really trying to = do a distinct you can select from the game table and do an exists = against plays and joints tables thus removing the distinct clause; but I = digress as the given query is most likely an over simplified query just = as example.

Partitioning = does nothing here as the query doesn=E2=80=99t filter on the partitioned = field thus no partition elimination.


= --Apple-Mail=_CEDA971B-2685-4B27-B54F-E132E8A8C237--