Re: BUG #18902: TRAP:: failed Assert("!is_sorted") in File: "createplan.c"

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: n(dot)kalinin(at)postgrespro(dot)ru, pgsql-bugs(at)lists(dot)postgresql(dot)org, Richard Guo <guofenglinux(at)gmail(dot)com>
Subject: Re: BUG #18902: TRAP:: failed Assert("!is_sorted") in File: "createplan.c"
Date: 2025-04-23 11:47:42
Message-ID: CAHewXNm=PzyhWgBvPJh9MYBhQzSjNYtRh1mq=ieCKWrKD2wMpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tender Wang <tndrwang(at)gmail(dot)com> 于2025年4月23日周三 19:03写道:

>
> I remove the Assert(!is_sorted), its plan looks like as below after adding
> below codes:
> if (presorted_keys > 0 && presorted_keys <
> list_length(best_path->outersortkeys))
> use_incremental_sort = true;
>
> QUERY PLAN
>
>
> ---------------------------------------------------------------------------------------------
> LockRows
> -> Merge Join
> Merge Cond: (local_tbl.c1 = ft1.c2)
> -> Index Scan using local_tbl_pkey on local_tbl
> -> Sort
> Sort Key: ft1.c2
> -> Foreign Scan
> Relations: (((ft1) INNER JOIN (ft2)) INNER JOIN
> (ft4)) INNER JOIN (ft5)
> -> Merge Join
> Merge Cond: (ft1.c2 = ft5.c1)
> -> Sort
> Sort Key: ft1.c2
> -> Merge Join
> Merge Cond: (ft1.c2 = ft4.c1)
> -> Sort
> Sort Key: ft1.c2
> -> Merge Join
> Merge Cond: (ft1.c1 =
> ft2.c1)
> -> Sort
> Sort Key: ft1.c1
> -> Foreign Scan
> on ft1
> -> Sort
> Sort Key: ft2.c1
> -> Foreign Scan
> on ft2
> -> Sort
> Sort Key: ft4.c1
> -> Foreign Scan on ft4
> -> Sort
> Sort Key: ft5.c1
> -> Foreign Scan on ft5
>

If is_sorted is true, it means that it's already fully sorted, the Sort
node doesn't need any more.
I suspect something went wrong somewhere else. I didn't look into the
details.

--
Thanks,
Tender Wang

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2025-04-23 13:01:16 Re: Command order bug in pg_dump
Previous Message Tender Wang 2025-04-23 11:03:28 Re: BUG #18902: TRAP:: failed Assert("!is_sorted") in File: "createplan.c"