pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dane Foster <studdugie@gmail.com>
Cc: psql-performance <pgsql-performance@postgresql.org>
Subject: Re: Plan weirdness. A sort produces more rows than the node beneath it
Date: Fri, 04 Aug 2023 11:31:57 -0400
Message-ID: <3661332.1691163117@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+WxinK_PeQBeZ-SWVqheHNjyjtD3QGZ5gZSzVKxHRYgUG-ktw@mail.gmail.com>
References: <CA+WxinKHxRUgDwbUfsKNiq5MXn8kRFayo0KqZzTmxXG93BbK4g@mail.gmail.com>
	<3658472.1691161821@sss.pgh.pa.us>
	<CA+WxinK_PeQBeZ-SWVqheHNjyjtD3QGZ5gZSzVKxHRYgUG-ktw@mail.gmail.com>

Dane Foster <studdugie@gmail.com> writes:
>> If the sort is the inner input to a merge join, this could reflect
>> mark-and-restore rescanning of the sort's output.  Are there a
>> whole lot of duplicate keys on the merge's other side?

> Yes. The course_id column's values repeat a LOT on the merge side.

Hmm.  The planner should avoid using a merge join if it knows that
to be true.  Maybe analyze'ing that table would prompt it to use
some other join method?

			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <3661332.1691163117@sss.pgh.pa.us>
Permalink:  ../3661332.1691163117@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3661332.1691163117@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, studdugie@gmail.com
  Subject: Re: Plan weirdness. A sort produces more rows than the node beneath it
  In-Reply-To: <3661332.1691163117@sss.pgh.pa.us>

* 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