pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-performance@lists.postgresql.org
Subject: Re: JOIN on partitions is very slow
Date: Mon, 23 Mar 2020 17:33:34 +0100
Message-ID: <7cdfd0d6-e4d3-7351-f13c-696460853657@gmx.net> (raw)
In-Reply-To: <CAHOFxGrjS+bFcD+Fbn7EqnJJ2oMPfQX_FEuDSkMjWxMYkBNemA@mail.gmail.com>
References: <CAFg0VMDrPS+CQF7z0e2SFNtW3wjWV_jVY2mkEWpF-eeg6jha=w@mail.gmail.com>
	<CAHOFxGodwHOJcn8ioEFfvh_kxZqXCJDP24PxXEkn3uhqFgQBKQ@mail.gmail.com>
	<CAFg0VMAkUn7AJuNo28sm2zXcsJUXKm+ACD2CmZZxZ801PZSiPw@mail.gmail.com>
	<CAHOFxGrjS+bFcD+Fbn7EqnJJ2oMPfQX_FEuDSkMjWxMYkBNemA@mail.gmail.com>

Michael Lewis schrieb am 23.03.2020 um 17:16:
> Yes. I can tweak the query. Version of postgres is 9.5.15. I have
> about 20 partitions for company_sale_account table. I do have an
> index on company name.
>
> I need to use DISTINCT as i need to remove the duplicates.
>
>
> DISTINCT is a sign of improper joins most of the time in my
> experience. Often, just changing to group by is faster

As none of the columns of the joined table are used, most probably
this should be re-written as an EXISTS condition.
Then neither GROUP BY nor DISTINCT is needed.








view thread (6+ messages)  latest in thread

Message-ID: <7cdfd0d6-e4d3-7351-f13c-696460853657@gmx.net>
Permalink:  ../7cdfd0d6-e4d3-7351-f13c-696460853657@gmx.net/
Also on:    postgresql.org/message-id/7cdfd0d6-e4d3-7351-f13c-696460853657@gmx.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: shammat@gmx.net, pgsql-performance@lists.postgresql.org
  Subject: Re: JOIN on partitions is very slow
  In-Reply-To: <7cdfd0d6-e4d3-7351-f13c-696460853657@gmx.net>

* 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