Re: FWD: Update touches unrelated indexes?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: FWD: Update touches unrelated indexes?
Date: 2006-06-30 06:43:54
Message-ID: 20925.1151649834@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Josh Berkus <josh(at)agliodbs(dot)com> forwards:
> I hope someone can explain what I'm seeing on our system. I've got a
> table with about four million rows in it (see schema below). Almost
> every column has one or two indexes. What I've found is that when I
> issue an update statement to zero out the content of a particular
> column, the pg_locks table indicates that every other, seemingly
> unrelated index is locked/changed.

This surprises you why?

> I expect the idx_test_table_col_27 index to have write locks during this
> operation but seeing RowExclusiveLock entries on every other index
> puzzles me. Interestingly enough these locks are not present if the
> table is smaller.

That last I don't believe at all --- PG updates every index on every row
update. Most likely the OP is just not querying pg_locks fast enough to
see the locks. If he's really concerned about update performance then
he probably needs to think harder about whether every one of those
indexes is really carrying its weight.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Peter Newman 2006-06-30 07:32:39 100% CPU
Previous Message Josh Berkus 2006-06-30 06:33:20 FWD: Update touches unrelated indexes?