pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: David Gauthier <dfgpostgres@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: creating a subset DB efficiently ?
Date: Sat, 9 Mar 2024 09:02:23 -0800
Message-ID: <f204d4ac-88b2-40de-ad01-3a30728404ff@aklaver.com> (raw)
In-Reply-To: <CAEs=6DmuXckUagHG2-mjfXWcjXhU6U7ZqpwB9WxxGdrGKi3DyQ@mail.gmail.com>
References: <CAEs=6DmuXckUagHG2-mjfXWcjXhU6U7ZqpwB9WxxGdrGKi3DyQ@mail.gmail.com>

On 3/8/24 08:22, David Gauthier wrote:
> Here's the situation....
> 
> - The DB contains data for several projects.
> - The tables of the DB contain data for all projects (data is not 
> partitioned on project name or anything like that)
> - The "project" identifier (table column) exists in a few "parent" 
> tables with many child... grandchild,... tables under them connected 
> with foreign keys defined with "on delete cascade".  So if a record in 
> one of the parent table records is deleted, all of its underlying, 
> dependent records get deleted too.

How many "... child... grandchild,... tables" ?

Do these tables constitute all the tables in the database?


> Related question...
> The "delete from par_tbl_a where project <> 'a' " is taking forever.  I 
> fear it's because it's trying to journal everything in case I want to 
> rollback.  But this is just in the archive DB and I don't mind taking 
> the risk if I can speed this up outside of a transaction.  How can I run 
> a delete command like this without the rollback recovery overhead ?

I am assuming that at the point you do  "delete from par_tbl_a where 
project <> 'a' " project a is no longer receiving data and its records 
are static. Further assuming there is a PK that you could order by, then 
it would seem the way to go would be to delete in batches as determined 
by the PK.


-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (6+ messages)  latest in thread

Message-ID: <f204d4ac-88b2-40de-ad01-3a30728404ff@aklaver.com>
Permalink:  ../f204d4ac-88b2-40de-ad01-3a30728404ff@aklaver.com/
Also on:    postgresql.org/message-id/f204d4ac-88b2-40de-ad01-3a30728404ff@aklaver.com

 · 

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: adrian.klaver@aklaver.com, dfgpostgres@gmail.com
  Subject: Re: creating a subset DB efficiently ?
  In-Reply-To: <f204d4ac-88b2-40de-ad01-3a30728404ff@aklaver.com>
  References: <CAEs=6DmuXckUagHG2-mjfXWcjXhU6U7ZqpwB9WxxGdrGKi3DyQ@mail.gmail.com> <f204d4ac-88b2-40de-ad01-3a30728404ff@aklaver.com>

* 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