pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alban Hertroys <haramrae@gmail.com>
To: Durgamahesh Manne <maheshpostgres9@gmail.com>
Cc: andreas@a-kretschmer.de
Cc: pgsql-general@lists.postgresql.org
Subject: Re: *Regarding brin_index on required column of the table
Date: Fri, 21 Sep 2018 21:08:29 +0200
Message-ID: <ADAB2B68-7FD7-4E3D-A7CE-F5D07A43A93A@gmail.com> (raw)
In-Reply-To: <CAJCZkoLuCYJ37kS4Z=6+XFd9qMY4ZcEnLiRZUZVsPq=eeCqOaA@mail.gmail.com>
References: <CAJCZko++xfddUpwC34FwPRvoK_9mEBecYY2eKUyvHnqNanND5w@mail.gmail.com>
	<f2a7181b-bc1e-bf05-5433-cf78e67e2f80@a-kretschmer.de>
	<CAJCZko+Z-Obp7XkNn3OWPWiOa2iEvM87F6kMyVVs-qrtk+c63g@mail.gmail.com>
	<CAJCZkoJaArzmpm208o=YPJQeZ5wB-3LJKiivUiA=9xpbUiAEkw@mail.gmail.com>
	<8f355e81-509b-aa88-f275-2620bcf98961@a-kretschmer.de>
	<CAJCZko+ZJQGZ=R43VwBAhCigm_L+abMNk3H_sXv9hWOQZOBOUg@mail.gmail.com>
	<CAJCZkoJE5=LjNrSwN_jbE=3J7mMDnNQneSKtxKNyrX=TKOy8SA@mail.gmail.com>
	<b67da906-d4dc-72c9-247e-576c934ce174@a-kretschmer.de>
	<CAJCZkoJr_ro=w8OMq8Ge0vZY8u4tggOG+U35Tisz67Y+qLosvg@mail.gmail.com>
	<CAJCZko+bB03wvLGVLJ3-JWUqaUWyKeZ5M2z=iLLHjOtJ_oQXQQ@mail.gmail.com>
	<CAJCZkoL63tYMBDwO-xaTqjDJ5ZzyCsz4zj-87DQ1vucMEmBxZQ@mail.gmail.com>
	<CAF-3MvOyLi55OOxoMAkvc998Bz20+XzWZXxPBHy-5Xa6n1m2vg@mail.gmail.com>
	<CAJCZkoKEbkeitrTDLBomioEaA_R843c4XRxOjEATe27yjEh_2w@mail.gmail.com>
	<CAJCZkoKnRJ+NrvTS0A5UUnJ1OY5-LJOWcgAeJ9Uef6x8WMCfiw@mail.gmail.com>
	<d42b255d-a758-437b-ed4b-e86d77b6af9f@a-kretschmer.de>
	<CAJCZkoLuCYJ37kS4Z=6+XFd9qMY4ZcEnLiRZUZVsPq=eeCqOaA@mail.gmail.com>



> On 21 Sep 2018, at 17:49, Durgamahesh Manne <maheshpostgres9@gmail.com> wrote:
> 
> <Query>

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.





view thread (24+ messages)  latest in thread

Message-ID: <ADAB2B68-7FD7-4E3D-A7CE-F5D07A43A93A@gmail.com>
Permalink:  ../ADAB2B68-7FD7-4E3D-A7CE-F5D07A43A93A@gmail.com/
Also on:    postgresql.org/message-id/ADAB2B68-7FD7-4E3D-A7CE-F5D07A43A93A@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: haramrae@gmail.com, maheshpostgres9@gmail.com, andreas@a-kretschmer.de
  Subject: Re: *Regarding brin_index on required column of the table
  In-Reply-To: <ADAB2B68-7FD7-4E3D-A7CE-F5D07A43A93A@gmail.com>
  References: <CAJCZko++xfddUpwC34FwPRvoK_9mEBecYY2eKUyvHnqNanND5w@mail.gmail.com> <CAJCZkoJaArzmpm208o=YPJQeZ5wB-3LJKiivUiA=9xpbUiAEkw@mail.gmail.com> <8f355e81-509b-aa88-f275-2620bcf98961@a-kretschmer.de> <CAJCZko+ZJQGZ=R43VwBAhCigm_L+abMNk3H_sXv9hWOQZOBOUg@mail.gmail.com> <CAJCZkoJE5=LjNrSwN_jbE=3J7mMDnNQneSKtxKNyrX=TKOy8SA@mail.gmail.com> <b67da906-d4dc-72c9-247e-576c934ce174@a-kretschmer.de> <CAJCZkoJr_ro=w8OMq8Ge0vZY8u4tggOG+U35Tisz67Y+qLosvg@mail.gmail.com> <CAJCZko+bB03wvLGVLJ3-JWUqaUWyKeZ5M2z=iLLHjOtJ_oQXQQ@mail.gmail.com> <CAJCZkoL63tYMBDwO-xaTqjDJ5ZzyCsz4zj-87DQ1vucMEmBxZQ@mail.gmail.com> <CAF-3MvOyLi55OOxoMAkvc998Bz20+XzWZXxPBHy-5Xa6n1m2vg@mail.gmail.com> <CAJCZkoKEbkeitrTDLBomioEaA_R843c4XRxOjEATe27yjEh_2w@mail.gmail.com> <CAJCZkoKnRJ+NrvTS0A5UUnJ1OY5-LJOWcgAeJ9Uef6x8WMCfiw@mail.gmail.com> <d42b255d-a758-437b-ed4b-e86d77b6af9f@a-kretschmer.de> <CAJCZkoLuCYJ37kS4Z=6+XFd9qMY4ZcEnLiRZUZVsPq=eeCqOaA@mail.gmail.com> <ADAB2B68-7FD7-4E3D-A7CE-F5D07A43A93A@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox