pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tv@fuzzy.cz>
Cc: pgsql-performance@postgresql.org
Subject: Re: slow full table update
Date: Thu, 13 Nov 2008 01:20:11 +0100
Message-ID: <491B72BB.6000703@fuzzy.cz> (raw)
In-Reply-To: <20663.1226523248@sss.pgh.pa.us>
References: <200811101729.14977@centrum.cz>
	<200811101730.11057@centrum.cz>
	<200811101730.15902@centrum.cz>
	<61593.89.102.139.23.1226335300.squirrel@sq.gransy.com>
	<200811121725.30238@centrum.cz>
	<63509.89.102.139.23.1226508479.squirrel@sq.gransy.com>
	<200811121825.26487@centrum.cz>
	<491B1653.3040600@archonet.com>
	<20663.1226523248@sss.pgh.pa.us>


> The explain plan tree only shows the time to fetch/compute the new rows,
> not to actually perform the update, update indexes, or fire triggers.
> If there is a big discrepancy then the extra time must be going into
> one of those steps.
> 
> 8.1 does show trigger execution time separately, so the most obvious
> problem (unindexed foreign key reference) seems to be excluded, unless
> the OP just snipped that part of the output ...

Yeah, that quite frequent problem with updates. Try to separate create a 
copy of the table, i.e.

CREATE TABLE test_table AS SELECT * FROM table;

and try to execute the query on it.

What tables do reference the original table using a foreign key? Do they 
have indexes on the foreign key column? How large are there referencing 
tables? Are these tables updated heavily and vacuumed properly (i.e. 
aren't they bloated with dead rows)?

I'm not sure if the FK constraints are checked always, or just in case 
the referenced column is updated. I guess the FK check is performed only 
in case of DELETE or when the value in the FK column is modified (but 
update of the primary key is not very frequent I guess).

Are there any triggers and / or rules on the table?

regards
Tomas



view thread (14+ messages)  latest in thread

Message-ID: <491B72BB.6000703@fuzzy.cz>
Permalink:  ../491B72BB.6000703@fuzzy.cz/
Also on:    postgresql.org/message-id/491B72BB.6000703@fuzzy.cz

 · 

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: tv@fuzzy.cz
  Subject: Re: slow full table update
  In-Reply-To: <491B72BB.6000703@fuzzy.cz>

* 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