pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Wilkinson <w.kevin.wilkinson@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: 10.2: high cpu usage on update statement
Date: Mon, 8 Apr 2019 06:21:56 -0700
Message-ID: <5af06316-25fc-cac6-7abe-44e1c8b61801@gmail.com> (raw)
In-Reply-To: <d4054043f1ba2bd30f2abbc9492ba4e5a1a0de15.camel@cybertec.at>
References: <214e8730-17b5-16be-afd6-8b6175dd15ab@gmail.com>
	<d4054043f1ba2bd30f2abbc9492ba4e5a1a0de15.camel@cybertec.at>

resolved. sorry for not posting the resolution earlier.

it was a good puzzler. turns out the postgresql server used 
network-attached disks. and the updated table had no index for the 
updated columns. so, the update required a serial scan of the table over 
the network. thus, the high cpu usage for updating a single row.

kevin

On 4/7/2019 11:41 PM, Laurenz Albe wrote:
> Kevin Wilkinson wrote:
>> on 10.2, we're seeing very high cpu usage when doing an update statement
>> on a relatively small table (1GB). one of the updated columns is text,
>> about 1k bytes. there are four threads doing similar updates
>> concurrently to the same table (but different rows). each thread does an
>> update about every two seconds, i.e., the tables gets updated every 1/2
>> second. the stack trace below shows the process stuck in reading the
>> update results. this seems very odd. has anyone seen something similar?
>> this is a modest server of 8 cores, all of which are 90% busy.
> Try to profile the server ("perf" on Linux) to see where the time is spent.
>
> Are there any foreign key constraints pointing to the table being updated?
> Then make sure that either no key column is updates or that the foreign
> keys are indexed.
>
> Yours,
> Laurenz Albe





view thread (4+ messages)

Message-ID: <5af06316-25fc-cac6-7abe-44e1c8b61801@gmail.com>
Permalink:  ../5af06316-25fc-cac6-7abe-44e1c8b61801@gmail.com/
Also on:    postgresql.org/message-id/5af06316-25fc-cac6-7abe-44e1c8b61801@gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: w.kevin.wilkinson@gmail.com
  Subject: Re: 10.2: high cpu usage on update statement
  In-Reply-To: <5af06316-25fc-cac6-7abe-44e1c8b61801@gmail.com>
  References: <214e8730-17b5-16be-afd6-8b6175dd15ab@gmail.com> <d4054043f1ba2bd30f2abbc9492ba4e5a1a0de15.camel@cybertec.at> <5af06316-25fc-cac6-7abe-44e1c8b61801@gmail.com>

* 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