Re: BUG #17494: High demand for displacement sort

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: pashutin(at)gmail(dot)com, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17494: High demand for displacement sort
Date: 2022-05-24 19:44:03
Message-ID: CAMkU=1xE+s8=8QxsVSDkMejnxbsZZMCKN_QVD+Wf_fsNoXjsXg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, May 24, 2022, 8:37 AM PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 17494
> Logged by: Владимир Пашутин
> Email address: pashutin(at)gmail(dot)com
> PostgreSQL version: 11.14
> Operating system: any
> Description:
>
> When working with sorting large lists, we often encounter an error:
> SQL state [XX000]; error code [0]; ERROR: could not resize shared memory
> segment \"/PostgreSQL.932873081\" to 100868096 bytes: Interrupted system
> call; nested exception is org.postgresql.util.PSQLException: ERROR: could
> not resize shared memory segment \"/PostgreSQL.932873081\" to 100868096
> bytes: Interrupted system call
> But we almost never need the whole list. Requests are always limited with
> LIMIT and OFFSET.
> However, from the analysis of the query plan, it turns out that first there
> is a complete sorting of the entire result and only then the selection of
> the required part of the rows.
>

This is not much of a bug report. PostgreSQL does have top-N sorts. Why
it is not used for some particular query is impossible to say without
seeing the query and/or query plan.

Even if not using top-N, it should still spill to disk instead of erroring
out like that, assuming your memory/parallel settings and load are
reasonable for your server. Again, with this amount of detail there is no
way to know.

Cheers,

Jeff

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2022-05-24 19:55:49 Re: BUG #17496: to_char function resets if interval exceeds 23 hours 59 minutes
Previous Message Andres Freund 2022-05-24 19:01:33 Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY