pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dimitrios Apostolou <jimis@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Moving data from huge table slow, min() query on indexed column taking 38s
Date: Thu, 6 Jul 2023 18:11:53 +0200 (CEST)
Message-ID: <a73dd30b-3dee-6e02-9eff-a90a8dd02e8f@gmx.net> (raw)
In-Reply-To: <096aa4b3-892e-7fa5-7370-3a1895e7d6a0@gmx.net>
References: <096aa4b3-892e-7fa5-7370-3a1895e7d6a0@gmx.net>

On Thu, 6 Jul 2023, Dimitrios Apostolou wrote:

> + First I chose the method to DELETE...INSERT everything.

Just to clarify, the query looked more like

   WITH rows AS ( DELETE FROM tbl_legacy RETURNING * )
     INSERT INTO tbl
       SELECT * FROM rows;

>   I noticed that the postgres process was growing without bounds, up to
>   the point that it consumed almost all of swap space and I had to kill
>   the command. Any idea why that happens?

Also note that my settings for work_mem, temp_buffers, shared_buffers etc
are all well below the RAM size and postgres has never shown unbound
growth again. Postgres version is 15.2.


Dimitris






view thread (6+ messages)  latest in thread

Message-ID: <a73dd30b-3dee-6e02-9eff-a90a8dd02e8f@gmx.net>
Permalink:  ../a73dd30b-3dee-6e02-9eff-a90a8dd02e8f@gmx.net/
Also on:    postgresql.org/message-id/a73dd30b-3dee-6e02-9eff-a90a8dd02e8f@gmx.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: jimis@gmx.net
  Subject: Re: Moving data from huge table slow, min() query on indexed column taking 38s
  In-Reply-To: <a73dd30b-3dee-6e02-9eff-a90a8dd02e8f@gmx.net>
  References: <096aa4b3-892e-7fa5-7370-3a1895e7d6a0@gmx.net> <a73dd30b-3dee-6e02-9eff-a90a8dd02e8f@gmx.net>

* 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