Re: Slow update statement

From: Tom Lane
Subject: Re: Slow update statement
Date: ,
Msg-id: 28597.1123514333@sss.pgh.pa.us
(view: Whole thread, Raw)
In response to: Re: Slow update statement  (Patrick Hatcher)
List: pgsql-performance

Tree view

Slow update statement  (Patrick Hatcher, )
 Re: Slow update statement  (John A Meinel, )
  Re: Slow update statement  (Patrick Hatcher, )
   Re: Slow update statement  (Tom Lane, )
    Re: Slow update statement  (Patrick Hatcher, )
 Re: Slow update statement  (Tom Lane, )
  Re: Slow update statement  (Patrick Hatcher, )
   Re: Slow update statement  (Tom Lane, )

Patrick Hatcher <> writes:
> Here's the table layout.  It's the first time I noticed this, but there
> is a PK on the cus_nbr and an index.  Does really need to be both and
> could this be causing the issue?  I thought that if a primary key was
> designated, it was automatically indexed.:

The duplicate index is certainly a waste, but it's no more expensive to
maintain than any other index would be; it doesn't seem likely that that
would account for any huge slowdown.

A long-shot theory occurs to me upon noticing that your join keys are
int8: 7.4 had a pretty bad hash function for int8, to wit it took the
low order half of the integer and ignored the high order half.  For
ordinary distributions of key values this made no difference, but I
recall seeing at least one real-world case where the information was
all in the high half of the key, and so the hash join degenerated to a
sequential search because all the entries went into the same hash
bucket.  Were you assigning cus_nbrs nonsequentially by any chance?

            regards, tom lane


pgsql-performance by date:

From: Tom Lane
Date:
Subject: Re: Finding bottleneck
From: Tom Lane
Date:
Subject: Re: Why hash join instead of nested loop?