Re: Extremely inefficient merge-join

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marcin Gozdalik <gozdal(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Extremely inefficient merge-join
Date: 2021-03-17 20:47:35
Message-ID: 3610142.1616014055@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Marcin Gozdalik <gozdal(at)gmail(dot)com> writes:
> Sometimes Postgres will choose very inefficient plan, which involves
> looping many times over same rows, producing hundreds of millions or
> billions of rows:

Yeah, this can happen if the outer side of the join has a lot of
duplicate rows. The query planner is aware of that effect and will
charge an increased cost when it applies, so I wonder if your
statistics for the tables being joined are up-to-date.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Marcin Gozdalik 2021-03-17 21:27:18 Re: Extremely inefficient merge-join
Previous Message Marcin Gozdalik 2021-03-17 16:10:14 Extremely inefficient merge-join