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 1hq0aS-0001p2-HY for pgsql-general@arkaria.postgresql.org; Tue, 23 Jul 2019 19:36:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hq0aQ-0003dC-IY for pgsql-general@arkaria.postgresql.org; Tue, 23 Jul 2019 19:36:34 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hq0aO-0003c1-Jg for pgsql-general@lists.postgresql.org; Tue, 23 Jul 2019 19:36:34 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hq0aF-0000ta-QL for pgsql-general@postgresql.org; Tue, 23 Jul 2019 19:36:32 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A499220F25; Tue, 23 Jul 2019 15:36:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 23 Jul 2019 15:36:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=H z6r27T8re3c63Xkf2G9VxUsSpi8w3Twa1lPkKruIbk=; b=cTdXcHsFCee+ByvXO 9zJ1R9IM4mTzj6GOA05CK7xRp2ca5aaGawGGX1q8UYtjzGsf0xZCnZjHOTercHRh X7g/dbw0/jJOQoUQ3yU8N8TvocQP2Sye8vjm5R8SVb8vAZ0F68b+ZnO8ZhsMVZ+0 NIYHpsgXhOyK0+3DLaYdIDKpSnu9u9PiItVWkbbla54cekYZz+QCrvV/iXV31ej1 I+8CnZDppIy1q+1UZsF0FXuNTmZ8nzdMmzlHwq/hCXH3vOx9BkLEe6666JHFC5yJ cp/GaHBtLbaJ8iq60xOqJWxxoLItd6kv5CzNpFpqZeJ/5RFdly4+nYe64BVHtrkH YDuMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=Hz6r27T8re3c63Xkf2G9VxUsSpi8w3Twa1lPkKruI bk=; b=g9oWXniyb31IPjurhUVmu9KtL4eMNob6q2/wOz9UIQexhef8n2UUPvT3R tAwc7eokTkd9EBhitODMWxPI7mLeMvXgha7OegarfHKl3S5Fp9vyZJRBaljpho6g tETphziPtyydJwk+h6tf4oTC8GbQQ5nUCmcFrT1vFUj8ptPvuWvB9YY8ak2jZlvm vmUG2tQZowwAdU8H3QuM63yd1qaoRiTO7AxPgfREfH2/ReUv+9No0tba0WacT3Ab 6lfDB+pxpVV5knTSfaBpKk595UsQYoWAEapYvj5ju4SQaDmixcJMU5gVLn2quTeh s2JV0I+KutR+rIWz7gC2o4niftMVA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrjeekgddufeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuffhomhgrihhnpehpohhsthhgrhgvsh hqlhdqrghrtghhihhvvgdrohhrghenucfkphepjedurddvuddvrdduhedtrddvtddvnecu rfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvg hrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id C3983380083; Tue, 23 Jul 2019 15:36:19 -0400 (EDT) Subject: Re: Too slow to create new schema and their tables, functions, triggers. To: PegoraroF10 , pgsql-general@postgresql.org References: <1563909633976-0.post@n3.nabble.com> From: Adrian Klaver Message-ID: <8db09c7e-dcbc-3f19-c72b-ccd085ff0b7a@aklaver.com> Date: Tue, 23 Jul 2019 12:36:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <1563909633976-0.post@n3.nabble.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/23/19 12:20 PM, PegoraroF10 wrote: > We have in a single database 190 identical schemas. Now, when we create a new > one, with exactly same structure as the previous ones, it takes 20 or 30 > minutes to finish. Usual time to finish that script was 30 seconds. > > Basically, my script creates an entire structure for a new customer: > - Create schema TempSchema; --just to be sure that nobody will connect until > it finishes > - create tables (100), constraints, functions, etc. > - import data using restore only data. > - rename TempSchema to production name. > > On second step, when creating tables, functions and so on, it takes > sometimes a minute just to create one table or one function. Can you show example of portion of script? Have you looked at the Postgres log during the above to see if there any relevant messages? > > So, does this happens because we have almost 200 schemas on that database ? > I´m almost sure about. > What do I need do to run my script as before ? Do I need to Reindex ? Vacuum > ? Or am I reaching a limit in a number of schemas in a Postgres database ? > > > > -- > Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html > > > -- Adrian Klaver adrian.klaver@aklaver.com