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 1jR9fC-0006ED-Se for pgsql-general@arkaria.postgresql.org; Wed, 22 Apr 2020 07:19:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jR9fB-00038m-GF for pgsql-general@arkaria.postgresql.org; Wed, 22 Apr 2020 07:19:17 +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 1jR9fB-00038f-3r for pgsql-general@lists.postgresql.org; Wed, 22 Apr 2020 07:19:17 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jR9f3-0005Hl-RX for pgsql-general@postgresql.org; Wed, 22 Apr 2020 07:19:15 +0000 Received: by mail-wm1-x342.google.com with SMTP id z6so1068431wml.2 for ; Wed, 22 Apr 2020 00:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=16UQJV0XpRH5G9COWS5KxWmU/CbdPbkAu3925uLRpAo=; b=atxCD4OAh8BhQvCAlLa1BqZ1TnIHGFk5w2TvxCcf374a8Qp3Es1bLEXCl+OK8612y3 UIDWgcFzcW8YTgb77Lwqd/2bunqAuTBQFwukFiAqwoqEZhFHB0vYuFwlif4zEDDJFq14 5vu9s7eBiTDR1pUHpb/zxpgQ3n/f5kLxxiVvvgHd88oMIXFet8FyJY0UIlIk/kGGeVbt mF4VqbCaV91J4Cph2EdKJ2aU3zP0l1E8gwqlDDsD1c5eJPwlnD21QoZsvpl2NYfI7Ftu +NBKlB/kesf90x/VWJYbjHAXRPLzr0kb032lyw7C3H5JRZ74dBSHkpz80+9WB2ReW/3b hJyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=16UQJV0XpRH5G9COWS5KxWmU/CbdPbkAu3925uLRpAo=; b=WU4tDCpK3PcajcERzYj8O+F3qyDUCdGgKIKdO8TCgz/37Xe2X7ur5Mszsez+TSYv7/ tI7vADRIxxDA6rr+P0L6o4ZkD7GpFU31f/0JQcvf5M4pkAuwix4qW5FPreG0mqzj1UcA x40Fg/QOCjY1dGv5gL46nhXMLC0S4Px9uKJjU5UoviZvW7u+4LA4ExELoBcdX03gYAiL +VyQN7UZ/JH6jppUJb76whsn9ce//QwwQ2MAFlBM/KJkKzHfxegFPjpXzyLvMYn+OKkZ Vl5cPms5rD4dK2ZbH0hQb8yDJ6WPmxc3rQOmqjrOeEoWT5lztS2kcOh/olBHbQ81/Uyz F49g== X-Gm-Message-State: AGi0Pubqtwz9VeCwKCcG0KZUGUKQBM/hcsK+ObWdjgJR1QWsTDMPJNcA 9sIi0yxvQPjkG76dT29g6dwzeUXAqCs= X-Google-Smtp-Source: APiQypKWYllg/cKeca6AeWariVE9iuGVK16h9EHr4fhGxXMnfKgcJwMXPqfD8jgWxdaS7t3He7Wl8w== X-Received: by 2002:a1c:c2d4:: with SMTP id s203mr9576646wmf.128.1587539947275; Wed, 22 Apr 2020 00:19:07 -0700 (PDT) Received: from dynamic-enqfe1d3rrvw19s41-pd01.res.v6.highway.a1.net (dynamic-enqfe1d3rrvw19s41-pd01.res.v6.highway.a1.net. [2001:871:60:8176:4208:2def:45f:c791]) by smtp.gmail.com with ESMTPSA id 74sm7236210wrk.30.2020.04.22.00.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 00:19:06 -0700 (PDT) Message-ID: <63b750ab4d35937cc1abe75387ce39050c2dc8f0.camel@cybertec.at> Subject: Re: how to slow down parts of Pg From: Laurenz Albe To: Kevin Brannen , "pgsql-general@postgresql.org" Date: Wed, 22 Apr 2020 09:19:05 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 2020-04-21 at 20:30 +0000, Kevin Brannen wrote: > I have an unusual need: I need Pg to slow down. I know, we all want our DB to go faster, > but in this case it's speed is working against me in 1 area. > > We have systems that are geo-redundant for HA, with the redundancy being handled by DRBD to keep the disks in sync, > which it does at the block level. For normal operations, it actually works out fairly well. [...] > The part that hurts so bad is when we do maintenance operations that are DB heavy, like deleting really old records out of > archives (weekly), moving older records from current tables to archive tables plus an analyze (every night), > running pg_backup (every night), other archiving (weekly), and vacuum full to remove bloat (once a quarter). > All of this generates a lot of disk writes, to state the obvious. > > The local server can handle it all just fine, but the network can't handle it as it tries to sync to the other server. The obvious and best answer is: get a faster network, or choose a different storage solution. Other than that, you can try to make the maintainance operations less resource intense: - partition the tables so that you can get rid of old data with DROP TABLE. The ANALYZE won't hurt, if you treat only the required tables. - use "pg_basebackup" with the "--max-rate" option About VACUUM, you may have a problem. Avoid the need for VACUUM (FULL) at any price. That usually requires tuning autovacuum to be faster, which means using more I/O. If you cannot find a sweet spot there, you have no alternative but getting better I/O (which, as I said in the beginning, would be the correct solution anyway). Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com