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.94.2) (envelope-from ) id 1uKzxz-00GA03-1T for pgsql-admin@arkaria.postgresql.org; Fri, 30 May 2025 13:40:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uKzxx-001ujD-Lu for pgsql-admin@arkaria.postgresql.org; Fri, 30 May 2025 13:40:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uKzxx-001uj5-9n for pgsql-admin@lists.postgresql.org; Fri, 30 May 2025 13:40:09 +0000 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uKzxu-000tQJ-1s for pgsql-admin@lists.postgresql.org; Fri, 30 May 2025 13:40:08 +0000 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-2db9e29d3bcso782075fac.1 for ; Fri, 30 May 2025 06:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748612405; x=1749217205; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=UIkPmB5N+OWtaLVYT5z2TUjBVlYlK978lHca21lykYk=; b=LSkWNMjDi3n+hIfHRTVPXZefIv3lHkaGlmt9+j/c1yLRefovdI34ZRbCNoiRiPA0X9 tg/T/nagajAkAqd7/HNZ21NVVeDl08IQmYY4t+K1S/2eckCDFUtClwwD9WS8JNDSFKzU eDeUB5ZPlmFYNVubJiVjhR2NYIkTyRmTiRO73GZ2waqQ01EmSdQqoECGtKkOUwptUT+S YWnBsqYyo+mTSfg06/XRGPmheaM3Y1rezE7lVSE6x80mpv45C2fjthNpOZ3IX1nGSisL TnjJBLjcb0YbxDHsGk/1mN2AlSMvaJdeB3Ih5wEkzjIYEwFAlklBv7hcPfxRnvrPEHZf ptQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748612405; x=1749217205; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UIkPmB5N+OWtaLVYT5z2TUjBVlYlK978lHca21lykYk=; b=JhG/PFbGd50a/VMQa3eALoR+Bcr5FT/sFGyJz8zVGZ5vak38V/HbgnNzEkRRkk8hsC nUOh5KIOZ3mJSd2LDPcAPpZqnqMT8vr+8aPMaL7nuaqDuReeI647G/ndiQpwq3tzS0SW AkKg6I7zwtLxwK7PaGdSb9RenU/ubOhT9jJT/VgHrs5gj8K077MEZplGQxaX3lYZK/rr mqBDeTRJXkXW0tLHpHRsId2Ax+jRpy1+rPWuG46DvS984iQEcy4MmxBw9FIkWMSUuuOB cYjJrpo9bHKT3/qjE4IDqXmuQaiUrkp6fxt+RrzhkKXroxtwfjoZLu6PvMMiN3InjHpW sOhQ== X-Gm-Message-State: AOJu0YxxIICBTc3JnnpjDSip25vK6X/CQ/9L4LlXSZujO0hu2CvDvcKI 7qu1OnStResObbHKImkb02BwFaDaldlvXDXqZOJkwwFDGrfoaz4v7RjDLy5chDoD7u3bbm8cMDq kfJ2xqWp6atTKwBX3X1vVpGJ9GzzAgLRh0g== X-Gm-Gg: ASbGncuHWIdDL51EnJBWI1ViFhxZtlKzAjLLHBCjWRyRKolpZfhe0JjhGXxy0FIMV/C eWF+mqMWuS7/kF/w8652NpdzS8lnjXnh6jE6/y5lliNuX65krRweviWbd2FKF1qiXx9eSQhoNjY KnUiDccoq2Kqx0thcV7TLm4N27hC1VfQ== X-Google-Smtp-Source: AGHT+IET4v6nB+Br0QOoTr/J1AW0bas/csjeip0pI0I5H1zEj3z5WlC0mObtHydelt8XzWq9CnobKagtgTrhzp31Bac= X-Received: by 2002:a05:6870:96a4:b0:2df:5323:520b with SMTP id 586e51a60fabf-2e92132a907mr1530856fac.19.1748612404958; Fri, 30 May 2025 06:40:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Joe Tailleur Date: Fri, 30 May 2025 07:39:53 -0600 X-Gm-Features: AX0GCFv2XcIVBx9XdKF1SF2NDhH8b6oo_tV5-m1z2Rh10cPMyF1SbkqWZEINRJI Message-ID: Subject: Re: Seeking Suggestions for Best Practices: Archiving and Migrating Historical Data in PostgreSQL To: Pgsql-admin Content-Type: multipart/alternative; boundary="0000000000003f5ddc06365a8d22" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003f5ddc06365a8d22 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Using table partitioning works well for me. I detach and move the partition to an archive schema; which I can then backup and restore into a separate database, and once that is complete, remove the table from the archive schema on the live database. Another thing I have done is to set up foreign tables so I can move records across databases. Joe. On Fri, May 30, 2025 at 1:51=E2=80=AFAM Motog Plus wr= ote: > Hi Team, > > We are currently planning a data archival initiative for our production > PostgreSQL databases and would appreciate suggestions or insights from th= e > community regarding best practices and proven approaches. > > **Scenario:** > - We have a few large tables (several hundred million rows) where we want > to archive historical data (e.g., older than 1 year). > - The archived data should be moved to a separate PostgreSQL database (on > a same or different server). > - Our goals are: efficient data movement, minimal downtime, and safe > deletion from the source after successful archival. > > - PostgreSQL version: 15.12 > - Both source and target databases are PostgreSQL. > > We explored using `COPY TO` and `COPY FROM` with CSV files, uploaded to a > SharePoint or similar storage system. However, our infrastructure team > raised concerns around the computational load of large CSV processing and > potential security implications with file transfers. > > We=E2=80=99d like to understand: > - What approaches have worked well for you in practice? > - Are there specific tools or strategies you=E2=80=99d recommend for ongo= ing > archival? > - Any performance or consistency issues we should watch out for? > > Your insights or any relevant documentation/pointers would be immensely > helpful. > > Thanks in advance for your guidance! > > Best regards, > Ramzy > --0000000000003f5ddc06365a8d22 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Using table partitioning works well for me.=C2=A0 I detach= =C2=A0and move the partition to an archive schema; which I can then backup = and restore into a separate database, and once that is complete, remove the= table from the archive schema on the live database.

Ano= ther thing I have done is to set up foreign tables so I can move records ac= ross databases.=C2=A0=C2=A0


Joe.


On Fri, May 30, 2025 at 1:51=E2=80= =AFAM Motog Plus <mplus7535@gmail= .com> wrote:
Hi Team,

We are currently planning a data archival initiative for our production Po= stgreSQL databases and would appreciate suggestions or insights from the co= mmunity regarding best practices and proven approaches.

**Scenario:**
- We h= ave a few large tables (several hundred million rows) where we want to arch= ive historical data (e.g., older than 1 year).
- The= archived data should be moved to a separate PostgreSQL database (on a same= or different server).
- Our goals are: efficient da= ta movement, minimal downtime, and safe deletion from the source after succ= essful archival.

- Postg= reSQL version: 15.12
- Both source and target databa= ses are PostgreSQL.

We e= xplored using `COPY TO` and `COPY FROM` with CSV files, uploaded to a Share= Point or similar storage system. However, our infrastructure team raised co= ncerns around the computational load of large CSV processing and potential = security implications with file transfers.

We=E2=80=99d like to understand:
= - What approaches have worked well for you in practice?
- Are there specific tools or strategies you=E2=80=99d recommend for on= going archival?
- Any performance or consistency iss= ues we should watch out for?

Your insights or any relevant documentation/pointers would be immensel= y helpful.

Thanks in adv= ance for your guidance!

= Best regards,=C2=A0=C2=A0
Ramzy
--0000000000003f5ddc06365a8d22--