Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vwfop-005VR7-0a for pgsql-general@arkaria.postgresql.org; Sun, 01 Mar 2026 12:22:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vwfoo-00Cvv9-0J for pgsql-general@arkaria.postgresql.org; Sun, 01 Mar 2026 12:22:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vwfon-00Cvv1-1q for pgsql-general@lists.postgresql.org; Sun, 01 Mar 2026 12:22:41 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vwfok-00000001vqj-2PI6 for pgsql-general@lists.postgresql.org; Sun, 01 Mar 2026 12:22:40 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-3591cc98871so1483453a91.3 for ; Sun, 01 Mar 2026 04:22:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772367758; cv=none; d=google.com; s=arc-20240605; b=TTIe7YFEltcdE4FBHInY+c0mwxcgS1LUtE7mDT+FPHgYv7lRxoEjqcX7Abp7NesI0K ObqW7+ZvylOj0AZYTrZ0ezSZqQpevvsPzFTgKdI34wi/1SdoPjNjpkzaZFyjRpF6f6MP zy3MSER4JUIkDn/yZDk0Q0IvjFt8uHvRtB+A1C2FJP6Mtq33rmJ225axEAN32TW7O2bg f6De/GaBji6FMrn6gwpcH+Ktyf6yHehYjne6l+KtOyXLmr6cIR8bfP4KE4jqjBqLrxEg u81EuEMna+n4n7mRaM3g825YSxvCmIwozomTXNUrHqrH322CEsNJfGXgtXO3cmxRrjxq 8qKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=JJMw9sJAkgv/FFfmmDr+wY2AQ5Vvz9WUyy2wNVE9t4o=; fh=SVwRzqxGachPxJDtSXVMZmHiGOaPm1qGNosR1GLID1s=; b=cwQYZze9SA1UdBK2yoTIPD9svXBqwLIZVTgQnBXxGhE4LYKShkVW2zcOk9zSGIq8Fs NOz3dCu8dam0bDDBNL2ZuXn2gNXmr37ma3MGixQgV62P1Zc5Xj9sE8sElrVdWAX1vDxJ JEqoQQy45W+Vl2OA5R/J05yy59kYeAxePUuVeGwh+nMyFkhNP/9sBZDsli70hOIUV6Vg 0txW3jB4QCgQQ6fVBxNuvRZc6ukNTRc9hM/rYePWWzSxx3FR0EParlNjgIGXm9HgITQJ g92JXn2zirvAjrgofcOqfpJuMo1SUbMMsqzK6HtcyJWTpOJW+Dz94Pw8u7+Mi0NRPr4L W9Jg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772367758; x=1772972558; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JJMw9sJAkgv/FFfmmDr+wY2AQ5Vvz9WUyy2wNVE9t4o=; b=EhqOt5hCR43ZaRseKe3eYFl+efv2DllDDUNE/N6MgCvQ0Nstt4HX25R0ieayzIdVWh bMtQAJApE43Rk9Y5QHlhALoKrPrr9Dq0KfLsVBuwfJcBIZ2LbOiXhdPgo3cYgtLFwBWE WqSp+vWVRa4x9ksvCS8vRpFY3vkCbzb0+78nYrSR2d/AYc2YtolaWw6n13ttg+jonU8d k9cqkjVkDgZDEwfVQNiMIT6hSisqPZXFwyp9vwaKoffC6MwQxkWaWj6v8TE2urNfaqJI hc9rrcumN/BDZ7s5C3A/DR66AUsusRkCt90IqIunJejQzVMq888kmpDioZA0+FA6pfYZ csuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772367758; x=1772972558; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JJMw9sJAkgv/FFfmmDr+wY2AQ5Vvz9WUyy2wNVE9t4o=; b=Byafd23DULRiRVqX5+M3bXA53OQxUKhlVVNIpYwpesfXce1wPGLnUBmmoKJnWWaTq4 VvAFXffYbYGZb244I1TMur/cXb6BTbg6lAGtBhfC7RpK2kPxwNZtZATS23sJNuMjY1YO k5D3rj1evi4c3H8IB3fv4dv99kOI2o3rl8lp+B8e4Mg8wxUR61a8YrahGo8kaAS/Z9BK nS1jLI11hiUhaF294JRQvoUz2aUX+mgA+2URKOmk+Hms0aN7R4LMkgTVEL5xSoJC7oR8 JZpTM06gV/yzxwhdQQuPVrmUuocr+/TYJ9SuxA4S2qpJyqbl2yBC4tndlZ4MUQWA+2c7 CfmQ== X-Gm-Message-State: AOJu0Yzso/rgBUPRf1Lnm6MvsWcNowHeN9FOHAIlzW42zhOlzQY2+yn1 KFwxUUSnvfPBa6uHk0Qu1VXYi4GZvU30C83l8TONyz6JEp5D6TbhO1dyQ4yDK7H1fM3OJ6cK6fO yiRyOE+sXcSVA6rGOfJUp7teHTpSYk44= X-Gm-Gg: ATEYQzzuve++oWmrLmNgYHGySeb56a6opAi6/xOAsJ/Txir8/MDW+U5ZV1EWlfG360P b2eAQWdCS+5Jv2U9DKUA3NqhnWq70vk1rqFH9cEEpJczCp0Yg9PMT3bVUdP+eZ2JZXtLGhnePwn PMYwkJEPN8JUOZ5RiCHQUKnNYDiwj3QZX4Y5ux8vcX9n1WyHuazghG8gRwX8I0MQ+bawsGkMWzJ w11w8RnE2s7haOLhEltBUl/JyTmNFYWdOxbEOYhpAiSpnIBGLjILsQtNb44FxL5CIZB19lx5JN/ lp1PUipD X-Received: by 2002:a17:90b:4d07:b0:353:6373:590b with SMTP id 98e67ed59e1d1-35965c27e71mr7699155a91.7.1772367757992; Sun, 01 Mar 2026 04:22:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Justin Swanhart Date: Sun, 1 Mar 2026 07:22:26 -0500 X-Gm-Features: AaiRm51x-Qqtf6-2kYR-SIPsiCo8RFPgX-tejGCQeqBd9L1xouo0FMEpHDuovJQ Message-ID: Subject: Re: Can "on delete cascade" dependency be used in pgdump or similar ? To: dfgpostgres Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000a06588064bf58601" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a06588064bf58601 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 27, 2026 at 5:40=E2=80=AFPM dfgpostgres wrote: > pg 15.15 on linux > > I have a DB with a table called "projects" which has a primary key column > called "project". Other child tables are linked in a primary/foreign key > relationship to "projects" with "on delete cascade". Each of those may > have grandchild tables linked in via other primary/foreign key > relationships, all with the "on delete cascade". Etc... . If I delete > project "a", it'll cascade delete the children, grandchild, etc... recs= . > All traces of project "a" will be gone. > > But I don't really want to lose the data from project "a", I want to > archive it in another DB (same DB server, different DB). The brain-numb > method I've been using thus far is to copy the whole DB via pgdump then u= se > that to create the DB "a_archive". Then (here's the wasteful part) > basically delete all the projects in "a-archive" EXCEPT for project "a". > Then, when that's done, go to the main DB and delete project "a". In > effect, I just archived all the data for project "a" and put it in the DB > called "a_archive".while relieving the main DB of the project "a" data. B= ut > what would be really neat is to leverage that cascade on delete stuff to > just pgdump project "a" and use that to create "a_archive". > > Can pgdump do something like that ? > Is there a better way to approach this problem of archiving one project > (remembering that we do have the "on delete cascade" set up) ? > > Thanks in Advance ! > > > Hi, I think a better way to approach this problem is using "change data capture" using the WAL. Projects such as Debezium [debezium.io] will allow you to process the changes from the server and capture the deletions from tables. You can archive the deleted rows however you like. --Justin --000000000000a06588064bf58601 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Fri, Feb 27, 202= 6 at 5:40=E2=80=AFPM dfgpostgres <dfgpostgres3@gmail.com> wrote:
pg=C2=A015.15 on linux

<= /div>
I have a DB with a=C2=A0table called "projects" which h= as a primary key column called "project".=C2=A0 Other child table= s are linked=C2=A0in a primary/foreign key relationship to "projects&q= uot; with "on delete cascade".=C2=A0 Each of those may have grand= child tables linked in via other primary/foreign key relationships, all wit= h the "on delete cascade".=C2=A0 Etc... .=C2=A0 If I delete proje= ct "a", it'll cascade delete the children,=C2=A0 grandchild, = etc...=C2=A0 recs.=C2=A0 All traces of project "a" will be gone.<= /div>

But I don't really want to lose the data from = project "a", I want to archive it in another DB (same DB server, = different DB).=C2=A0 The brain-numb method I've been using thus far is = to copy the whole DB via pgdump=C2=A0then use that to create the DB "a= _archive".=C2=A0 Then (here's the wasteful part) basically delete = all the projects in "a-archive" EXCEPT for project "a".= =C2=A0 Then, when that's done, go to the main DB and delete project &qu= ot;a". In effect, I just archived all the data for project "a&quo= t; and put it in the DB called "a_archive".while relieving the ma= in DB of the project "a" data. But what would be really neat is t= o leverage that cascade on delete stuff to just pgdump=C2=A0project "a= " and use that to create "a_archive".=C2=A0=C2=A0
=
Can pgdump=C2=A0do something like that ?
Is there = a better way to approach this problem of archiving one project (remembering= that we do have the "on delete cascade" set up) ?

=
Thanks in Advance !

=C2=A0
<= /blockquote>

Hi,

I think a bett= er way to approach this problem is using "change data capture" us= ing the WAL.=C2=A0 Projects such as Debezium [debezium.io] will allow you to process the changes from the server an= d capture the deletions from tables.=C2=A0 You can archive the deleted rows= however you like.

--Justin=C2=A0
--000000000000a06588064bf58601--