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 1lXCAV-0002TC-Pv for pgsql-novice@arkaria.postgresql.org; Fri, 16 Apr 2021 00:17:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lXCAU-0005G0-Kg for pgsql-novice@arkaria.postgresql.org; Fri, 16 Apr 2021 00:17:06 +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 1lXCAU-0005Fs-Ev for pgsql-novice@lists.postgresql.org; Fri, 16 Apr 2021 00:17:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lXCAS-0001Fy-EL for pgsql-novice@lists.postgresql.org; Fri, 16 Apr 2021 00:17:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 13G0H1253969079; Thu, 15 Apr 2021 20:17:01 -0400 From: Tom Lane To: "Daniel Heath" cc: pgsql-novice@lists.postgresql.org Subject: Re: Prepared statement invalidation In-reply-to: References: Comments: In-reply-to "Daniel Heath" message dated "Fri, 16 Apr 2021 10:09:38 +1000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3969077.1618532221.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 15 Apr 2021 20:17:01 -0400 Message-ID: <3969078.1618532221@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Daniel Heath" writes: > I've found that when I add a new column, I sometimes get a spike of erro= rs on the application side due to prepared statement query plans getting i= nvalidated, causing transactions to rollback. > The error is: > ERROR: cached plan must not change result type = > Is there a way to make postgres recalculate the query plan instead of fa= iling the transaction when a new column is added? No. It'd be easy enough to remove that restriction on the server side, but we're afraid that it would break applications, which probably aren't expecting the result rowtype of a prepared query to be different from what they were told (perhaps only milliseconds earlier). I'd say the short answer is "don't use prepared queries, or if you do, spell out the columns you want instead of saying SELECT *". regards, tom lane > Thanks, > Daniel Heath