pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Massive delete of rows, how to proceed?
4+ messages / 4 participants
[nested] [flat]

* Massive delete of rows, how to proceed?
@ 2006-11-24 18:43 Arnau <arnaulist@andromeiberica.com>
  2006-11-25 15:45 ` Massive delete of rows, how to proceed? Peter Childs <peterachilds@gmail.com>
  2006-11-27 08:44 ` Re: Massive delete of rows, how to proceed? Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Arnau @ 2006-11-24 18:43 UTC (permalink / raw)
  To: pgsql-performance

Hi all,

   I have a table with statistics with more than 15 million rows. I'd
like to delete the oldest statistics and this can be about 7 million
rows. Which method would you recommend me to do this? I'd be also
interested in calculate some kind of statistics about these deleted
rows, like how many rows have been deleted for date. I was thinking in
creating a function, any recommendations?

Thank you very much
-- 
Arnau



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Massive delete of rows, how to proceed?
  2006-11-24 18:43 Massive delete of rows, how to proceed? Arnau <arnaulist@andromeiberica.com>
@ 2006-11-25 15:45 ` Peter Childs <peterachilds@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Peter Childs @ 2006-11-25 15:45 UTC (permalink / raw)
  To: pgsql-performance

On 24/11/06, Arnau <arnaulist@andromeiberica.com> wrote:
> Hi all,
>
>    I have a table with statistics with more than 15 million rows. I'd
> like to delete the oldest statistics and this can be about 7 million
> rows. Which method would you recommend me to do this? I'd be also
> interested in calculate some kind of statistics about these deleted
> rows, like how many rows have been deleted for date. I was thinking in
> creating a function, any recommendations?


Copy and drop old table. If you delete you will have a massive problem
with a bloated table and  vacuum will not help unless you expect the
table to grow to this size regulally otherwise vacuum full will take
ages.

Peter.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Massive delete of rows, how to proceed?
  2006-11-24 18:43 Massive delete of rows, how to proceed? Arnau <arnaulist@andromeiberica.com>
@ 2006-11-27 08:44 ` Merlin Moncure <mmoncure@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Merlin Moncure @ 2006-11-27 08:44 UTC (permalink / raw)
  To: arnaulist@andromeiberica.com; +Cc: pgsql-performance

On 11/25/06, Arnau <arnaulist@andromeiberica.com> wrote:
> Hi all,
>
>    I have a table with statistics with more than 15 million rows. I'd
> like to delete the oldest statistics and this can be about 7 million
> rows. Which method would you recommend me to do this? I'd be also
> interested in calculate some kind of statistics about these deleted
> rows, like how many rows have been deleted for date. I was thinking in
> creating a function, any recommendations?

a function, like an sql statement, operates in a single transaction
and you are locking quite a few records in this operation.  merlin's
3rd rule: long running transactions are (usually) evil.

my gut says moving the keeper records to a swap table, dropping the
main table, and swapping the tables back might be better.  However,
this kind of stuff can cause problems with logged in sessions because
of plan issues, beware.

do not write a function to delete records row by row unless you have
exhausted all other courses of action.

merlin



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Massive delete of rows, how to proceed?
@ 2006-11-26 00:35 andrew@pillette.com
  0 siblings, 0 replies; 4+ messages in thread

From: andrew@pillette.com @ 2006-11-26 00:35 UTC (permalink / raw)
  To: pgsql-performance

I don't believe DROP is necessary; use TRUNCATE instead. No need to re-create dependent objects.

"Peter Childs" <peterachilds@gmail.com> wrote ..
> On 24/11/06, Arnau <arnaulist@andromeiberica.com> wrote:
> > Hi all,
> >
> >    I have a table with statistics with more than 15 million rows. I'd
> > like to delete the oldest statistics and this can be about 7 million
> > rows. Which method would you recommend me to do this? I'd be also
> > interested in calculate some kind of statistics about these deleted
> > rows, like how many rows have been deleted for date. I was thinking in
> > creating a function, any recommendations?
> 
> 
> Copy and drop old table. If you delete you will have a massive problem
> with a bloated table and  vacuum will not help unless you expect the
> table to grow to this size regulally otherwise vacuum full will take
> ages.
> 
> Peter.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
> 
>                http://archives.postgresql.org



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2006-11-27 08:44 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-24 18:43 Massive delete of rows, how to proceed? Arnau <arnaulist@andromeiberica.com>
2006-11-25 15:45 ` Peter Childs <peterachilds@gmail.com>
2006-11-27 08:44 ` Merlin Moncure <mmoncure@gmail.com>
2006-11-26 00:35 Re: Massive delete of rows, how to proceed? andrew@pillette.com

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