Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iL54p-0002NA-KY for pgsql-general@arkaria.postgresql.org; Thu, 17 Oct 2019 12:40:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iL54o-0005B4-Bc for pgsql-general@arkaria.postgresql.org; Thu, 17 Oct 2019 12:40:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iL54n-0005As-Tl for pgsql-general@lists.postgresql.org; Thu, 17 Oct 2019 12:40:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iL54l-0007iJ-OR for pgsql-general@lists.postgresql.org; Thu, 17 Oct 2019 12:40:20 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9HCeFxw027712; Thu, 17 Oct 2019 08:40:15 -0400 From: Tom Lane To: Alexander Pyhalov cc: Laurenz Albe , "pgsql-general@lists.postgresql.org" Subject: Re: PostgreSQL memory usage In-reply-to: References: ,<9d662d4588db8f77f8bb2c9bab360f77021aadc5.camel@cybertec.at> Comments: In-reply-to Alexander Pyhalov message dated "Thu, 17 Oct 2019 12:29:04 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20764.1571316015.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 17 Oct 2019 14:40:15 +0200 Message-ID: <20765.1571316015@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Pyhalov writes: > However, one table has 2250 partitions and I've seen several selects to = this table (based on the primary key of individual partitions) with a hug= e IN () list (about 500 keys). Don't expect this to be efficient, but uns= ure that these queries caused such memory consumption. Yeah, it could be that it's just the number of partitions involved in the query that's causing the memory bloat. v10 is not bright about pruning uninteresting partitions from a query (v12 is better), so there will be 2250 tables involved so far as the planner and executor are concerned. And then if you've got a large/complex WHERE clause, that's probably copied and modified for each of those tables :-(. We don't generally recommend having more than a hundred or so partitions, because of issues like this. v12 is starting to make it feasible to have more, but only in limited use-cases. regards, tom lane