pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Sabino Mullane <greg@turnstep.com>
To: pgsql-performance@postgresql.org
Subject: Re: Deleting certain duplicates
Date: Tue, 20 Apr 2004 11:15:58 -0000
Message-ID: <82428c807d3c47fbcd0c013dbcab12b5@biglumber.com> (raw)
In-Reply-To: <F2D63B916C88C14D9B59F93C2A5DD33F0B9219@cisxa.cmc.int.ec.gc.ca>


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
 
> So I was thinking maybe of doing the deletion in chunks, perhaps based on
> reception time.
> Are there any suggestions for a better way to do this, or using multiple
> queries to delete selectively a week at a time based on the reception_time.
> I would say there are a lot of duplicate entries between mid march to the
> first week of April.
 
You are on the right track, in that dividing up the table will help. However,
you cannot divide on the reception_time as that is the unique column. Analyze
your data and divide on a row with a fairly uniform distribution over the
time period in question. Then copy a segment out, clean it up, and put it
back in. Make sure there is an index on the column in question, of course.
 
For example, if 1/10 of the table has a "units" of 12, you could do something
like this:
 
CREATE INDEX units_dev ON forecastelement (units);
 
CREATE TEMPORARY TABLE units_temp AS SELECT * FROM forecastelement WHERE units='12';
 
CREATE INDEX units_oid_index ON units_temp(oid);
 
(Delete out duplicate rows from units_temp using your previous query or something else)
 
DELETE FROM forecastelement WHERE units='12';
 
INSERT INTO forecastelement SELECT * FROM units_temp;
 
DELETE FROM units_temp;
 
Repeat as needed until all rows are done. Subsequent runs can be done by doing a
 
INSERT INTO units_temp SELECT * FROM forecastelement WHERE units='...'
 
and skipping the CREATE INDEX steps.
 
On the other hand, your original deletion query may work as is, with the addition
of an oid index. Perhaps try an EXPLAIN on it.
 
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200404200706
 
-----BEGIN PGP SIGNATURE-----
 
iD8DBQFAhQVWvJuQZxSWSsgRAvLEAKDCVcX3Llm8JgszI/BBC1SobtjVawCfVGKu
ERcV5J2JolwgZRhMbXnNM90=
=JqET
-----END PGP SIGNATURE-----





view thread (5+ messages)

Message-ID: <82428c807d3c47fbcd0c013dbcab12b5@biglumber.com>
Permalink:  ../82428c807d3c47fbcd0c013dbcab12b5@biglumber.com/
Also on:    postgresql.org/message-id/82428c807d3c47fbcd0c013dbcab12b5@biglumber.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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: greg@turnstep.com
  Subject: Re: Deleting certain duplicates
  In-Reply-To: <82428c807d3c47fbcd0c013dbcab12b5@biglumber.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