Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 7AD486340D8 for ; Sat, 7 Nov 2009 23:47:58 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 84488-04 for ; Sun, 8 Nov 2009 03:47:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 70DE6633317 for ; Sat, 7 Nov 2009 23:47:50 -0400 (AST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 868461E043F; Sun, 8 Nov 2009 11:47:45 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id X9RiQHcgMSqW; Sun, 8 Nov 2009 11:47:43 +0800 (WST) Received: from [10.1.1.6] (124-169-36-119.dyn.iinet.net.au [124.169.36.119]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 4516B1E043D; Sun, 8 Nov 2009 11:47:43 +0800 (WST) Message-ID: <4AF63F5B.2060300@postnewspapers.com.au> Date: Sun, 08 Nov 2009 11:47:39 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.1) Gecko/20090715 Thunderbird/3.0b3 MIME-Version: 1.0 To: Aris Samad-Yahaya CC: pgsql-performance@postgresql.org Subject: Re: CREATE TABLE slowing down significantly over time References: <008801ca6021$c1cc7630$45656290$@com> In-Reply-To: <008801ca6021$c1cc7630$45656290$@com> X-Enigmail-Version: 0.97a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.11 tagged_above=-10 required=5 tests=BAYES_05=-1.11 X-Spam-Level: X-Archive-Number: 200911/81 X-Sequence-Number: 36249 On 8/11/2009 11:15 AM, Aris Samad-Yahaya wrote: > It used to take about 15 seconds to create those 300 tables in a new > schema (when there were only a few schemas, say about 50). It now takes > about 3 minutes (and now we have about 200 schemas, with more data but > not hugely so). 200 schemas, 300 tables per schema. That's sixty THOUSAND tables. > * Is the problem caused by the increasing number of schemas? and increasing table count, I expect. You do batch the table and schema creation into a single transaction, right? If not, do that first, rather than creating each table in a separate transaction (ie: relying on autocommit). It may also be worth thinking about the app's design. Is a new schema and 300 new tables for each user really the best way to tackle what you're doing? (It might be, but it's a question worth asking yourself). -- Craig Ringer