pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Siraj G <tosiraj.g@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Backup certain months old data
Date: Mon, 22 Jan 2024 21:25:58 -0800
Message-ID: <17ee71d1-036f-4c4d-a1ff-eb5d1f23a68e@aklaver.com> (raw)
In-Reply-To: <CAC5iy636E-_Y7Jb0-DCiuH09SzsXZk+x+O8eWht_Z8gOaJoDNw@mail.gmail.com>
References: <CAC5iy636E-_Y7Jb0-DCiuH09SzsXZk+x+O8eWht_Z8gOaJoDNw@mail.gmail.com>

On 1/22/24 19:11, Siraj G wrote:
> Hello!
> 
> I would like to know how we can backup certain months old data from 
> PgSQL and then delete it. The intent is to backup everything that is 
> older than 2 quarters to a blob storage and delete it, to improve 
> performance and reduce billing.

1) Postgres does not track the insert/update times of data, so unless 
you have fields that track that you will not be able to do that.

2) If you do have a way of telling the times for all the records, are 
you sure that removing the data on a time basis will be clean enough 
operation that it will not leave the data in a compromised state?

3) Have you considered partitioning? See here:

https://www.postgresql.org/docs/current/ddl-partitioning.html

> 
> Regards
> Siraj

-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (3+ messages)

Message-ID: <17ee71d1-036f-4c4d-a1ff-eb5d1f23a68e@aklaver.com>
Permalink:  ../17ee71d1-036f-4c4d-a1ff-eb5d1f23a68e@aklaver.com/
Also on:    postgresql.org/message-id/17ee71d1-036f-4c4d-a1ff-eb5d1f23a68e@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, tosiraj.g@gmail.com
  Subject: Re: Backup certain months old data
  In-Reply-To: <17ee71d1-036f-4c4d-a1ff-eb5d1f23a68e@aklaver.com>
  References: <CAC5iy636E-_Y7Jb0-DCiuH09SzsXZk+x+O8eWht_Z8gOaJoDNw@mail.gmail.com> <17ee71d1-036f-4c4d-a1ff-eb5d1f23a68e@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