pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Vilson farias <vilson.farias@digitro.com.br>
Cc: pgsql-admin@postgresql.org
Subject: Re: Deleting large amount of data.
Date: Tue, 27 Aug 2002 08:16:54 -0700 (PDT)
Message-ID: <20020827081250.G72641-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <016e01c24dc6$5bf743f0$98a0a8c0@dgtac>


On Tue, 27 Aug 2002, Vilson farias wrote:

>
>
> Thanks for ask my post, Mr. Szabo.
>
>    Thanks for worry about my performance problems, but they are natural for
> my database, once my hardware isn't a Ferrari and my table has more than 2
> milion of touples and it's related with a lot of other very high populated
> tables. I realized I can keep no longer than 6 mounths of data in these
> tables, so I would like to remove older data every night. I didn't write any
> code yet and I can't start testing the best way in my databases, so I'm
> posting here to get some advices. I'm worried about performance problems
> that could raise when a start removing 12000 touples in a single transaction
> once I don't know how PostgreSQL works internally. Can a single transaction
> deal with so many data without problem or overloading transaction buffers
> (or something like that) or do I need to split deletion process in smaller
> sets of data?

12000 rows shouldn't be a big deal.  I assume you're adding about the same
number per day basically, so it's a rotating window.

The things to be sure of are that the column you're deleting by is indexed
(using the definition below this means dt_inicial or dt_final has to be
part of the constraint).  You should check with explain to make sure it's
using the index (if it says it's not, you should analyze the table and try
again).  Also, if you're running 7.2, you should probably do a vacuum
afterwards (without full) and after say a couple of weeks of this, if
you notice your disk space is increasing, there are some configuration
options which can help (look for the free space map options in the
configuration file).

>
> My main table wich has more than 2milion of touples :
> CREATE TABLE cham_chamada (
>        cod_bxs              integer NOT NULL,
>        chave                integer NOT NULL,
>        identificacao        integer NOT NULL,
>        dt_inicial           timestamp  NOT NULL,
>        indicadora           integer,
>        cod_categoria        integer,
>        identidadea          varchar(20),
>        dt_final             timestamp ,
>        juntor               integer,
>        indicadorb           integer,
>        identidadeb          varchar(20),
>        flg_chamada          char(1),
>        flg_liberacao        char(1),
>        temp_total           integer,
>        ddd                  smallint,
>        cod_liberjuntor      integer,
>        cod_resultcham       integer,
>        cod_fds              integer,
>        cifra_origem         integer,
>        csp                  char(2),
>        conta                integer,
>        ramal                varchar(20),
>        ultimo_ramal         varchar(20),
>        CONSTRAINT XPKcham_chamada PRIMARY KEY (dt_inicial, cod_bxs, chave,
> identificacao)
>
> )
> ;
>
> CREATE INDEX XIE1cham_chamada ON cham_chamada
> (
>        dt_final                       ,
>        identidadea
> );
>
> CREATE INDEX XIE2cham_chamada ON cham_chamada
> (
>        dt_final                       ,
>        flg_chamada
> );




view thread (4+ messages)

Message-ID: <20020827081250.G72641-100000@megazone23.bigpanda.com>
Permalink:  ../20020827081250.G72641-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20020827081250.G72641-100000@megazone23.bigpanda.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-admin@postgresql.org
  Cc: sszabo@megazone23.bigpanda.com, vilson.farias@digitro.com.br
  Subject: Re: Deleting large amount of data.
  In-Reply-To: <20020827081250.G72641-100000@megazone23.bigpanda.com>
  References: <016e01c24dc6$5bf743f0$98a0a8c0@dgtac> <20020827081250.G72641-100000@megazone23.bigpanda.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