Re: atrocious update performance

From: Greg Stark <gsstark(at)mit(dot)edu>
To: "Rosser Schwarz" <rschwarz(at)totalcardinc(dot)com>
Cc: "'Postgresql Performance'" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: atrocious update performance
Date: 2004-03-16 07:31:06
Message-ID: 871xnt1c5h.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


"Rosser Schwarz" <rschwarz(at)totalcardinc(dot)com> writes:

> Actually, there are no foreign keys to those columns. Once they're
> populated, I'll apply a foreign key constraint and they'll refer to the
> appropriate row in the prod and subprod tables, but nothing will
> reference account.cust.[sub]prodid. There are, of course, several foreign
> keys referencing account.cust.custid.

Just to be clear, the foreign key constraints they're worrying about are not
constraints on the table you're updating. They're constraints on other tables
referring to the table you're updating.

Since you're updating the column here postgres has to be sure nothing is
referring to the old value you're obliterating, and to do that it has to
select for possible records in the referencing tables referring to the value.
If there are any references in other tables referring to this column then you
need an index on the column in the referencing table to be able to update the
column in referenced table efficiently.

--
greg

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Shridhar Daithankar 2004-03-16 07:38:49 Re: atrocious update performance
Previous Message Joe Conway 2004-03-16 07:11:35 Re: [PERFORM] rapid degradation after postmaster restart