Slow delete by table with reference to him slef.

From: pginfo <pginfo(at)t1(dot)unisoftbg(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Slow delete by table with reference to him slef.
Date: 2002-12-04 15:45:00
Message-ID: 3DEE22FC.9E00901D@t1.unisoftbg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

CREATE TABLE mytable (
"ids" name NOT NULL,
"myref" name,
CONSTRAINT "a_doc_pkey" PRIMARY KEY ("ids"),
CONSTRAINT "$1" FOREIGN KEY ("myref") REFERENCES "mytable" ("ids") ON
DELETE NO ACTION ON UPDATE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)

I put in the table ~ 100 000 records and after it I try to delete all
the records with:
delete from mytable;

The delete take ~ 1 h. And the processor usage is ~ 100 %.

I think the problem is in the reference to him self.

How can I improve this preformance.

For example in oracle I set all myref's to NULL and the delete is very
fast.

regards,
ivan.

Browse pgsql-general by date

  From Date Subject
Next Message Scott Lamb 2002-12-04 15:55:31 Re: User date_trunc function in plpgsql function
Previous Message annachau 2002-12-04 15:41:27 User date_trunc function in plpgsql function