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 1mq1UT-0001dq-ME for pgsql-performance@arkaria.postgresql.org; Wed, 24 Nov 2021 23:15:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mq1UR-0002vL-Uj for pgsql-performance@arkaria.postgresql.org; Wed, 24 Nov 2021 23:15:47 +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 1mq1UR-0002vC-Hb for pgsql-performance@lists.postgresql.org; Wed, 24 Nov 2021 23:15:47 +0000 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mq1UO-0002xZ-Or for pgsql-performance@lists.postgresql.org; Wed, 24 Nov 2021 23:15:46 +0000 Received: by mail-io1-xd33.google.com with SMTP id c3so5263409iob.6 for ; Wed, 24 Nov 2021 15:15:44 -0800 (PST) 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=H3BtqMDwxkL8fSGVSqzucY4T8xn8K20BukflBfQrlks=; b=cZ9W0a6Nzk6yaUNgtLExykGEXCh5rNQV0b5YykrItngq2IUNrpFHbmifj1XFOpsJoq X43YUxXHqGz1JWFaoRB/ri8YluA1A0I4qNsXPjWdzTeu5sLtZFOr50TL92OwjAMXstMe lo2wFqMSOIqMPVewADBzSyZk0vVQasciZOkMb1GQ0iO8VJv4RORUDNLBYTDq/PDJmwX/ OIgXuF257inbiliJlXQni9qt/QFsiElsUBvD7OaI+nqoVULeml6zqqiv3vpv9yiIrhke qO3vtySqeJCBb5274yzEuq4smjWsoKHASbeEropCjSMHLJo5e5pufjY/7053Z3luNQx9 pXYw== 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=H3BtqMDwxkL8fSGVSqzucY4T8xn8K20BukflBfQrlks=; b=64dqxHzo1SRVwghIlBjSb/mJk0fbolOjl/CbW2ROgajpnx79QSgJQDlLcBKJ8Q/gvv rtAA4pubeBqA/6CJVTFljaEymnFecnkZ9WyJQwKsauAznIOga4QPfFXZFmFfdhBioGZS CeCgvSd8s2HEA7wg2uh9lqqCKmBY8sJXdynQaeoxd/aEOROPGljZDAK4UhBPzJ1QUFl2 7/wMEr34W5BilQL1StiJe4rEh0RXX2p/ZFc52gKHBKqQSNgj1usK2jJ1o6uaG7PqKP4Y VeOte0qwBTDkKcTbfwn8Tu4ObNxIp4tXuo/lh51fD92tLD6LvruM0LXQ3JP4b8CODJkG h+pQ== X-Gm-Message-State: AOAM532SILcFzUJBwCc6Pijh+7+s5WEE24/UaqrpS1j+NX0Jd/QSp+rD wycUfkyFmmqAnFpGycYIULLzHA== X-Google-Smtp-Source: ABdhPJzGcCV3oUU4HRenYVGWktdUX+HCJNYzS3IUHRSruM947TcUhH/Bf/ycC7QuToTprSaWSq/fNA== X-Received: by 2002:a05:6638:25c4:: with SMTP id u4mr21449734jat.87.1637795743795; Wed, 24 Nov 2021 15:15:43 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f16sm719391iov.33.2021.11.24.15.15.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 15:15:43 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 50823800876; Wed, 24 Nov 2021 17:15:42 -0600 (CST) Date: Wed, 24 Nov 2021 17:15:42 -0600 From: Justin Pryzby To: Robert Creager Cc: Tom Lane , Thomas Munro , pgsql-performance@lists.postgresql.org, Barry Litt Subject: Re: Need help identifying a periodic performance issue. Message-ID: <20211124231542.GB17618@telsasoft.com> References: <20211117231815.GF17618@telsasoft.com> <1ADFE43B-5A43-40DA-B039-2D7E5FD82B6C@spectralogic.com> <20211118054221.GJ17618@telsasoft.com> <8048B2EE-E627-4818-9FB4-00E78D245CC8@spectralogic.com> <2977426.1637271745@sss.pgh.pa.us> <40167D9A-8FDE-4F47-9AD0-897F7242A6B7@spectralogic.com> <77BB05DD-9543-4AD2-A58C-533D71864637@spectralogic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Wed, Nov 24, 2021 at 10:44:12PM +0000, Robert Creager wrote: > I forgot, I had reloaded postgres, but had not re-started our app, so the connections wouldn’t have that plan setting on them. Re-doing now. Are you sure? GUC changes should be applied for existing sessions, right ? Would you send the logs surrounding the slow COPY ? Specifically including the autovacuum logs. > We are at it again. I have a DELETE operation that’s taking 48 minutes so far. Before, you had slow COPY due to FKs. Now you have a slow DELETE, which you only alluded to before. > So how do we avoid this query plan? Do we need to start doing explicit analyzes after every delete? If your DELETE is deleting the entire table, then I think you should VACUUM anyway (or else the next inserts will bloat the table). Or (preferably) use TRUNCATE instead, which will set relpages=0 and (one supposes) avoid the bad plans. But read the NOTE about non-mvcc behavior of TRUNCATE, in case that matters to you. But first, I believe Thomas was suggesting to put plan_cache_mode back to its default, and (for testing purposes) try using issue DISCARD PLANS. On Fri, Nov 19, 2021 at 10:08:02AM +1300, Thomas Munro wrote: > Just to understand what's going on, it'd be interesting to know if the > problem goes away if you *just* inject the DISCARD PLANS statement > before running your COPYs, but if that doesn't help it'd also be > interesting to know what happens if you ANALYZE each table after each > COPY. Are you running any explicit ANALYZE commands? How long do > your sessions/connections live for? -- Justin