Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDUDq-0002OV-1J for pgsql-general@arkaria.postgresql.org; Mon, 08 Apr 2019 13:22:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDUDo-0002o0-Ku for pgsql-general@arkaria.postgresql.org; Mon, 08 Apr 2019 13:22:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDUDo-0002lH-7i for pgsql-general@lists.postgresql.org; Mon, 08 Apr 2019 13:22:00 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDUDl-0006Nz-Pz for pgsql-general@postgresql.org; Mon, 08 Apr 2019 13:21:59 +0000 Received: by mail-pf1-x442.google.com with SMTP id c8so7619034pfd.10 for ; Mon, 08 Apr 2019 06:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=aLzagBit2G9Ye4xAvvNno6MYy3gNJNTRZqwLZHtn71M=; b=KOGiNCq3hJWl6yJXGHQRHj6be2W/W3LmASn1q8Yd/YzMP0utoTh+/12Z4b4o2+5wcB utFXhsFSMUoe5jyIOBDk4rVTS7XVpOa7eQoz0zy/SmPYWRs3zI9HRG7FStIm/ck4/S46 Psg1BZRjsNiz6lucf0t8Jq3AHXoD7swwKn2fywAt1U9n2wdPoYnAtbpEXcBRPJuG9+Se jbNeX4JBEanOazt6CsneTsCUTm3xsJy9nEUdwk49wYOjwX9Gm5dTpmnMXRq27empktbD O7gNC3LU7Pval2/aW7iS1T0LKxhwjIefr5zB9yQQUxCzyLMWlEinxuuISncqOVkVi1RM IDSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=aLzagBit2G9Ye4xAvvNno6MYy3gNJNTRZqwLZHtn71M=; b=mxhzWp/tTLCFaYzkY8okhzTvunPToLJf0LQS3Ud7VbpSQM0BiUTkRdt5Iz7FvTVmcG 4hW+mYwDVsZf2+ZiBEpUbAbeeoQzMj8bhU0bsjU5zfitz7LMQN76xhhEa8WVSoZ+hXoK PnLXAXjqs8wQtsD7oDeVqBXM1w5PCBKJi+PI1VyVLjuiCroh2SOW+wSeURYSLplJqecs CE+9aWN2LrUcEDmIZxEQj09BtCACukhgi5GTDFpAc4yAwJMaCcjSp64n5ZpGvXXaIZLq cenZ5LERHgo7lI/yCVBAC+hKpdHec1+19IJSD4JsQX34Emv7EL27B1vUtP254bmPBXON qvlw== X-Gm-Message-State: APjAAAUuOxoUirvSqIqeaSKUFi8DFw77p0W80dhJcrX7FWX/4oxDrP63 z8+j6bV+28jn4bm8FNr6VQVrh7d+ X-Google-Smtp-Source: APXvYqz5sa+sr94QHK16ObHznOAfCxYxI2EABZyyLfxvwv1C4HLYh5mTMmupceIojSjSvgGdxLcHRw== X-Received: by 2002:a63:e304:: with SMTP id f4mr26747577pgh.374.1554729716116; Mon, 08 Apr 2019 06:21:56 -0700 (PDT) Received: from ?IPv6:2601:646:c201:b55:ec64:520b:7ddb:b389? ([2601:646:c201:b55:ec64:520b:7ddb:b389]) by smtp.gmail.com with ESMTPSA id i15sm43039906pfd.162.2019.04.08.06.21.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 06:21:55 -0700 (PDT) Subject: Re: 10.2: high cpu usage on update statement To: pgsql-general@postgresql.org References: <214e8730-17b5-16be-afd6-8b6175dd15ab@gmail.com> From: Kevin Wilkinson Message-ID: <5af06316-25fc-cac6-7abe-44e1c8b61801@gmail.com> Date: Mon, 8 Apr 2019 06:21:56 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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