Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fXbzo-0005gf-Iw for pgsql-general@arkaria.postgresql.org; Tue, 26 Jun 2018 00:38:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fXbzm-0001VI-0E for pgsql-general@arkaria.postgresql.org; Tue, 26 Jun 2018 00:38:10 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fXbzl-0001V6-Lc for pgsql-general@lists.postgresql.org; Tue, 26 Jun 2018 00:38:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fXbzj-0006HP-3K for pgsql-general@postgresql.org; Tue, 26 Jun 2018 00:38:08 +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 w5Q0bwf1030855; Mon, 25 Jun 2018 20:37:58 -0400 From: Tom Lane To: Andres Freund cc: Akshaya Acharya , pgsql-general@postgresql.org Subject: Re: Too many range table entries error In-reply-to: <20180625181410.fg5xejq4qsbnryl2@alap3.anarazel.de> References: <20180625081006.jnxgmsysq2biacnc@alap3.anarazel.de> <20180625181410.fg5xejq4qsbnryl2@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Mon, 25 Jun 2018 11:14:10 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21973.1529973478.1@sss.pgh.pa.us> Date: Mon, 25 Jun 2018 20:37:58 -0400 Message-ID: <21974.1529973478@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2018-06-25 13:46:06 +0530, Akshaya Acharya wrote: >> Our entire application-all our business logic-is built as layers of views >> inside the database. The ref counts sort of multiple at each layer, hence >> the large number. > That still doesn't explain how you realistically get to 40k references, > and how that's a reasonable design. The short answer here is that even if the system accepted queries with that many tables, it's really unlikely to perform acceptably --- in fact, I'm a bit astonished that you even found a way to reach this error without having waited a few hours beforehand. And we are *not* going to promise to fix all the performance issues you will hit with a schema design like this. Redesign. Please. regards, tom lane