Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRhrd-00033I-1g for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Jul 2017 16:36:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dRhrb-0001TK-UV for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Jul 2017 16:36:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dRhrb-0001SV-36 for pgsql-bugs@postgresql.org; Sun, 02 Jul 2017 16:36:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dRhrS-0000OF-Mt for pgsql-bugs@postgresql.org; Sun, 02 Jul 2017 16:36:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v62GaQ8l029650; Sun, 2 Jul 2017 12:36:26 -0400 From: Tom Lane To: dmigowski@ikoffice.de cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14726: Memory consumption of PreparedStatement In-reply-to: <20170702090956.1469.41812@wrigleys.postgresql.org> References: <20170702090956.1469.41812@wrigleys.postgresql.org> Comments: In-reply-to dmigowski@ikoffice.de message dated "Sun, 02 Jul 2017 09:09:56 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29648.1499013386.1@sss.pgh.pa.us> Date: Sun, 02 Jul 2017 12:36:26 -0400 Message-ID: <29649.1499013386@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org dmigowski@ikoffice.de writes: > I concluded that the query plan of the statement, which I uploaded to despez > would result in 30MB of memory footprint! > https://explain.depesz.com/s/gN2 Really? There's 132 plan nodes in that plan. I could believe that we're eating several KB per plan node, but not 220KB per node. > * How can I determine the memory footprint of prepared statements? It's not something we track specifically. > * Wouldn't it be useful if we could give a memory limit for prepared > statements on the server, so that PostgreSQL automatically evicts them if > more are prepared, maybe by using an LRU list? I'd be against that, as it pretty much would destroy the point of having prepared statements at all --- if the server forgets them at random, or even just has to re-prepare them unexpectedly, it's not holding up its end of the contract. It's the application's job to use that resource in a prudent manner, just like any other SQL resource. > PostgreSQL could automatically replan them when they get used again, I > think. This view seems like a poster child for why that would be a bad idea --- that query has to take a mighty long time to plan. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs