Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g3Qn6-0008Jj-QO for pgsql-general@arkaria.postgresql.org; Fri, 21 Sep 2018 19:08:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g3Qn5-0006PR-FL for pgsql-general@arkaria.postgresql.org; Fri, 21 Sep 2018 19:08:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g3Qn5-0006PJ-7R for pgsql-general@lists.postgresql.org; Fri, 21 Sep 2018 19:08:35 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g3Qn3-00076N-BO for pgsql-general@lists.postgresql.org; Fri, 21 Sep 2018 19:08:34 +0000 Received: by mail-ed1-x529.google.com with SMTP id y20-v6so11576182edq.2 for ; Fri, 21 Sep 2018 12:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=2cMYZDCbst/sB2FuQYwGJiYb0y6ibKPiqzijoV/HDJI=; b=sToARJB+QtyCk7cJW25WSQ0IhU7pkyAVJro3dIlY8WexdT0mcRLQlcqZm2rX8ruIFL 7RaNF4j2HCvcNunxFeHAm+TgifJdxzpUq77nT4MuddtQsHebEeXfmo29wfQ3nS3BVRDz IKSh3R5SG+nVHLIsnS9isHSUz76tvTYJ/c+P4JfRo/ZxJ2awxMtIyRlySzZVtSb9WSB6 A59RvTO83wVwkYfH+2SVKk2lNk62ysb61iTwpF7K7BucfX+ZdJkAhucKwAQk6bbUMgnI pYE8sKS9075UnTCkeIOyfMwo2VV7e/y0B/cgCN8axardp/u83oIL26N/8LN4J4D6hf3l HHlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=2cMYZDCbst/sB2FuQYwGJiYb0y6ibKPiqzijoV/HDJI=; b=fb9+JhqdHdpuzRzSirqfcmmMCTVf5emYr+qCvnWC9Fwfb9u6KhGgMhc6j8iCUrXkNs uN+qFFZcDf48KrdCutTUanakZt9TyimEYtWphNVkcRlw3fNY6c/y5PwrrTYg908vGR0x VoGEisQ+n4U4O9gp7T2WDtNqxZQLoMKpFxrQLiZO/kMsa3C20eEZbp0YMmqOJ817Fg8/ zLHUhydmVISgLrMv9y6LAiRJ+SX5wKreKg4tGWDdT2yBXnSO23tEZFplKUav1z273AVm XJPGSHXXu27M8oi0pNv1rPb/eFKn+08ZScmPe57ePdVlzMv3kIpXXnL3o7uNQ3SNbBFe z/LA== X-Gm-Message-State: APzg51BC+66iOMaYcpvxdc9F2pAGPShQj+0JCzyx1ct+KVeYpemhKQ/d jHi58uD3UP9b7kYMfSMNr9mnXVEq X-Google-Smtp-Source: ANB0VdbhsD53C4nUMt/boc8xWXnZ/HDo6b7MrF0NLZqKjvNmBG09LQhcjH/QtzPx6EKqRQmy/F5WNg== X-Received: by 2002:a50:9662:: with SMTP id y89-v6mr14124386eda.32.1537556912358; Fri, 21 Sep 2018 12:08:32 -0700 (PDT) Received: from hollewijn.internal (217-19-30-105.dsl.cambrium.nl. [217.19.30.105]) by smtp.gmail.com with ESMTPSA id d2-v6sm2164356edd.55.2018.09.21.12.08.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 12:08:31 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: *Regarding brin_index on required column of the table From: Alban Hertroys In-Reply-To: Date: Fri, 21 Sep 2018 21:08:29 +0200 Cc: andreas@a-kretschmer.de, pgsql-general@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <8f355e81-509b-aa88-f275-2620bcf98961@a-kretschmer.de> To: Durgamahesh Manne X-Mailer: Apple Mail (2.3445.9.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On 21 Sep 2018, at 17:49, Durgamahesh Manne = wrote: >=20 > Considering how hard you try to get rid of duplicates, I'm quite = convinced that you're at least short a few join conditions. Getting rid = of duplicates early has the added benefit of having to aggregate fewer = rows, which should drastically improve the performance of this query. In addition, your approach of using both distinct and group by raises a = red flag that you're fighting symptoms (most likely: duplicate results) = without understanding their causes. I can't think of a single situation = where both are justified in the same (sub-)query. Alban Hertroys -- If you can't see the forest for the trees, cut the trees and you'll find there is no forest.