pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: xiaohongjun@stu.xidian.edu.cn
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18935: The optimiser's choice of sort doubles the execution time.
Date: Mon, 19 May 2025 17:23:58 +0200
Message-ID: <4d33efcf76aa2a7d48c90c74e1889f4a571a787e.camel@cybertec.at> (raw)
In-Reply-To: <18935-afc77176f41fbecb@postgresql.org>
References: <18935-afc77176f41fbecb@postgresql.org>

On Mon, 2025-05-19 at 12:42 +0000, PG Bug reporting form wrote:
> database4=# explain analyze SELECT t0.c0 FROM t0 INNER JOIN t1* ON
> ((t1.c0)=(((t1.c0)-(((((t1.c0)*('(-795716537,-245904803]'::int4range)))-(range_merge(t1.c0,
> t0.c0))))))) GROUP BY t0.c0;
>
> [explicitly disabling sort leads to a faster execution plan]

I see no bug here.
The join condition is so complicated that the planner has a hard
time estimating the number of result rows for the join.
It guesses way to low, so the sort is expensive, and avoiding it is cheaper.

The optimizer cannot be perfect, particularly in the face of complicated
expressions like that.

Yours,
Laurenz Albe





view thread (5+ messages)  latest in thread

Message-ID: <4d33efcf76aa2a7d48c90c74e1889f4a571a787e.camel@cybertec.at>
Permalink:  ../4d33efcf76aa2a7d48c90c74e1889f4a571a787e.camel@cybertec.at/
Also on:    postgresql.org/message-id/4d33efcf76aa2a7d48c90c74e1889f4a571a787e.camel@cybertec.at

 · 

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-bugs@postgresql.org
  Cc: laurenz.albe@cybertec.at, xiaohongjun@stu.xidian.edu.cn, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18935: The optimiser's choice of sort doubles the execution time.
  In-Reply-To: <4d33efcf76aa2a7d48c90c74e1889f4a571a787e.camel@cybertec.at>

* 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