Please recommend me the best bulk-delete option - Mailing list pgsql-general

From Siva Palanisamy
Subject Please recommend me the best bulk-delete option
Date
Msg-id 90F0F47595235141A4380FCF01B0185B2243DCA184@CHN-HCLT-EVS07.HCLT.CORP.HCL.IN
Whole thread Raw
Responses Re: Please recommend me the best bulk-delete option  ("David Johnston" <polobo@yahoo.com>)
Re: Please recommend me the best bulk-delete option  ("Tomas Vondra" <tv@fuzzy.cz>)
List pgsql-general
Hi All,

I'm using PostgreSQL 8.1.4. I've 3 tables: one being the core (table1), others are dependents (table2,table3). I
inserted70000 records in table1 and appropriate related records in other 2 tables. As I'd used CASCADE, I could able to
deletethe related records using DELETE FROM table1; It works fine when the records are minimal in my current PostgreSQL
version.When I've a huge volume of records, it tries to delete all but there is no sign of deletion progress for many
hours!Whereas, bulk import, does in few minutes. I wish to do bulk-delete in reasonable minutes. I tried TRUNCATE also.
Like,TRUNCATE table3, table2,table1; No change in performance though. It just takes more time, and no sign of
completion!From the net, I got few options, like, deleting all constraints and then recreating the same would be fine.
But,no query seems to be successfully run over 'table1' when it's loaded more data! 
Please recommend me the best solutions to delete all the records in minutes.

CREATE TABLE table1(
        t1_id   SERIAL PRIMARY KEY,
        disp_name       TEXT NOT NULL DEFAULT '',
        last_updated TIMESTAMP NOT NULL DEFAULT current_timestamp,
        UNIQUE(disp_name)
    ) WITHOUT OIDS;

CREATE UNIQUE INDEX disp_name_index on table1(upper(disp_name));

CREATE TABLE table2 (
        t2_id           SERIAL PRIMARY KEY,
        t1_id   INTEGER REFERENCES table1 ON DELETE CASCADE,
        type    TEXT
    ) WITHOUT OIDS;

CREATE TABLE table3 (
        t3_id           SERIAL PRIMARY KEY,
        t1_id   INTEGER REFERENCES table1 ON DELETE CASCADE,
        config_key      TEXT,
        config_value    TEXT
    ) WITHOUT OIDS;

Regards,
Siva.

::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Session variables and C functions
Next
From: "David Johnston"
Date:
Subject: Re: Please recommend me the best bulk-delete option