Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f14kM-0007R5-CE for pgsql-general@arkaria.postgresql.org; Wed, 28 Mar 2018 06:39:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f14kK-000850-VV for pgsql-general@arkaria.postgresql.org; Wed, 28 Mar 2018 06:39:44 +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.89) (envelope-from ) id 1f14j7-00005r-My for pgsql-general@lists.postgresql.org; Wed, 28 Mar 2018 06:38:29 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f14j4-0003tZ-8s for pgsql-general@lists.postgresql.org; Wed, 28 Mar 2018 06:38:28 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 2278441008; Wed, 28 Mar 2018 08:38:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id etZ7bKM2HdnT; Wed, 28 Mar 2018 08:38:21 +0200 (CEST) Message-ID: <1522216691.2363.13.camel@cybertec.at> Subject: Re: Connection hangs on new created schema From: Laurenz Albe To: Juan Manuel Cuello , pgsql-general@lists.postgresql.org In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Date: Wed, 28 Mar 2018 07:58:11 +0200 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Juan Manuel Cuello wrote: > I have a postgresql database with around 4000 schemas. Each schema has around > the same 65 tables. There are 8 processes connected to the database (it is a web app). > Each process has only one direct connection to the database (no connection pool). > > Everything works ok until a new schema (with all its tables, indices, etc) > is added to the database. When this happens, the next query made to the database > takes too long, sometimes more than a minute o two. Also I see a high DB CPU usage > during that lapse. Then everything continues working ok as usual and CPU drops to normal levels. > > I'm mostly sure this has to do with the amount of schemas, maybe related to relcache, > but not sure why creating new schemas causes all this and where to look to solve this problem. If you know the slow query EXPLAIN (ANALYZE, BUFFERS) it and see where the time is spent. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com