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 1oeiZO-00020P-FE for pgsql-general@arkaria.postgresql.org; Sat, 01 Oct 2022 19:54:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oeiZN-00017o-33 for pgsql-general@arkaria.postgresql.org; Sat, 01 Oct 2022 19:54:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeiZM-00017f-OY for pgsql-general@lists.postgresql.org; Sat, 01 Oct 2022 19:54:40 +0000 Received: from smtp.burggraben.net ([2a01:4f8:140:510a::3]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeiZK-0005kU-ID for pgsql-general@lists.postgresql.org; Sat, 01 Oct 2022 19:54:40 +0000 Received: from elch.exwg.net (elch.exwg.net [IPv6:2001:470:7120:1:127b:44ff:fe4f:148d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "elch.exwg.net", Issuer "R3" (not verified)) by smtp.burggraben.net (Postfix) with ESMTPS id 5F960C00312 for ; Sat, 1 Oct 2022 21:54:36 +0200 (CEST) Received: by elch.exwg.net (Postfix, from userid 1000) id DF47B3AB08; Sat, 1 Oct 2022 21:54:35 +0200 (CEST) Date: Sat, 1 Oct 2022 21:54:35 +0200 From: Christoph Moench-Tegeder To: pgsql-general@lists.postgresql.org Subject: Re: Example code Re: Singleton SELECT inside cursor loop Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.2.7 (2022-08-07) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ## Ron (ronljohnsonjr@gmail.com): > The question then is "why am I just now seeing the problem?"  We've been > using v12 for two years, and it just happened. > > The only recent change is that I upgraded it from RDS 12.10 to 12.11 a > couple of weeks ago. That's correlation, but no proof for causality. Now that you've confirmed that you have indeed a mismatch between generic and custom plan, you could compare those (EXPLAIN EXECUTE) and see where the generic plan goes wrong. Otherwise, prime suspects are bad statistics (Were stats accurate before the update? How about now? Ran VACUUM ANALYZE recently? If not, does it improve matters?) If would help if you could compare execution plans with plans from before the update, but I guess you didn't document those? Regards, Christoph -- Spare Space