Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oAXZ0-0007Ai-Sw for pgsql-performance@arkaria.postgresql.org; Sun, 10 Jul 2022 14:05:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oAXYx-0007fF-Rq for pgsql-performance@arkaria.postgresql.org; Sun, 10 Jul 2022 14:05:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oAXYx-0007f6-8y for pgsql-performance@lists.postgresql.org; Sun, 10 Jul 2022 14:05:31 +0000 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oAXYo-0004gJ-VG for pgsql-performance@lists.postgresql.org; Sun, 10 Jul 2022 14:05:29 +0000 Received: by mail-il1-x12d.google.com with SMTP id b12so1762315ilh.4 for ; Sun, 10 Jul 2022 07:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=tw19VB0GTBfnjafiSgjDQGAIPXEmSTigGQfipPhAPq8=; b=2MpyX9CYHFnyQcCO1GjWHiuY9dvINQWG5H74VnLfftUa77RgiLQeUrcRGYUyKMryHa 2WbDtuZdg5Na2HdS4lEOjSkLTNwmdZbATADAZMzQlPR+5FfrnhUbrMzp/7Z3CuhlS9c0 bAv9LNb8DdqZyJKc2WyaS9HVkI50/KRhlQ1b0XRrHsDNBI5sb8N5kLxKmOaHqqmK9054 Kuf9cP9benxMmuU9LgIV0TQhzL1+UEE0itZ94PaZvBMZYFXsvwjMwwnLqtOFkqQYDg2A O+GVWh2Jl8G9FEeJ+LbvTG7ol3PT7qGjQG+2GCfMV4B3b1ppJ+Nmt7LSCVufWHNaVfua neDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=tw19VB0GTBfnjafiSgjDQGAIPXEmSTigGQfipPhAPq8=; b=0F+TClukgmORuUJAdrxCI7EuGRxVkluGsLatR/jnJ11kbbEgvylExgoeYVMlxBPeLM oy6TkbDtLNMRrMYPBEp5La5ejn6KgrRjwacI00Gra345CUJpNpvMJsMUL69+Q1HGFJpO dpiEht4QY7Y35qp/NlCLSyTrDszWn3z4TSS1D8Lzd6Jxi5fnYSD/JdgALnQ9KqJgU51c Th9DSXvEvTU+92NtMJ8zg+fi7a5LEfj4mHTQhYAJJpiT+LfNz7EvRMTqTFF6+b38b+Hj 9vpm6pv5fspBBycDgOwQ9lOf5EH4+L/a7TudXk5PRXp/3BCzW62aAXWiIHaY0vmxaS9Y 05ng== X-Gm-Message-State: AJIora+E5dJ36Jz4GnuBS+qmqcxSA9ERETQX3gQTKPaaMv2rXFFGh3V6 UDzXNtuW/qxYclN+mo+Mr+P5ywdhDeqUwQ== X-Google-Smtp-Source: AGRyM1unwWMYogL9F96T5eV8+JdBwwaYq6veroryCOOqyRGqPVs0LlKbjMKBdu0RBI3vHhMRx8NQbg== X-Received: by 2002:a92:da4c:0:b0:2d5:4942:151c with SMTP id p12-20020a92da4c000000b002d54942151cmr7298460ilq.54.1657461921596; Sun, 10 Jul 2022 07:05:21 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f1-20020a02a101000000b0033f3b201d1dsm1830702jag.21.2022.07.10.07.05.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jul 2022 07:05:21 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 43369800957; Sun, 10 Jul 2022 09:05:20 -0500 (CDT) Date: Sun, 10 Jul 2022 09:05:20 -0500 From: Justin Pryzby To: Nathan Ward Cc: pgsql-performance@lists.postgresql.org Subject: Re: Occasional performance issue after changing table partitions Message-ID: <20220710140519.GN13040@telsasoft.com> References: <24A451C3-1F45-48ED-B747-4BA17C249AF1@daork.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <24A451C3-1F45-48ED-B747-4BA17C249AF1@daork.net> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Jul 10, 2022 at 04:55:34PM +1200, Nathan Ward wrote: > I am running Postgres 13 on CentOS 7, installed from the yum.postgresql.org repo. It doesn't sound relevant, but what kind of storage systems is postgres using ? Filesystem, raid, device. Is the high CPU use related to to autovacuum/autoanalyze ? > The issue I am having, is that when the daily data usage aggregation runs, sometimes we have a big performance impact, with the following characteristics which happen *after* the aggregation job runs in it usual fast time of 12s or so: > - The aggregation runs fast as per normal > - Load on the server goes to 30-40 - recall we have quite high “max connections” to keep throughput high when the client is far (16ms) from the server I suggest to install and enable autoexplain to see what's running slowly here, and what its query plans are. It seems possible that when the daily aggregation script drops the old partitions, the plan changes for the worse. I'm not sure what the fix is - maybe you just need to run vacuum or analyze on the new partitions soon after populating them. For good measure, also set log_autovacuum_min_duration=0 (or something other than -1) (and while you're at it, log_checkpoints=on, and log_lock_waits=on if you haven't already). Note that postgres doesn't automatically analyze parent tables, so you should maybe do that whenever the data changes enough for it to matter. -- Justin