Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 8A2021636116 for ; Fri, 6 Jul 2012 23:28:01 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SnKkZ-0006g8-L2 for pgsql-performance@postgresql.org; Sat, 07 Jul 2012 02:28:00 +0000 Received: by pbbrp8 with SMTP id rp8so15563243pbb.19 for ; Fri, 06 Jul 2012 19:27:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:x-gm-message-state; bh=cSSfur/r9GAsTrKedbujWacaVWxA6kq88UqCaEQ9i34=; b=dvgU0OC2jvXAk8iPnDADH0HcDa8i18zRZ+eOdvZ/poRnr3aXRPTVCHi/jzcTt9LMv2 2htKbcnC6eLGQxBOBqq4R5+qYwJdPjw6vH9lsx99SNnS9b7VDsm+6ic8lPiujL35vxP3 CiYSqWAhqHKbyirgXuzXdqU3rDHV/zxmGaxDG/++icPfdxD8U9G9wycDxmDxExpE7EJf V0Lq/MqvOckXnplq06ur1AWjmEJANWzwhPN42ZGDfmoCBboWTeImPtBOlVdaL6Zbkck8 UbpWaWafjnZDTyz4BwUoFjWXBTe5DDgpg6tII3u/pQmqB7Cgkn6xwNgVUprmMzE7wVPT hxIg== Received: by 10.68.223.164 with SMTP id qv4mr23819548pbc.20.1341628064927; Fri, 06 Jul 2012 19:27:44 -0700 (PDT) Received: from ayaki.localdomain (124-169-169-118.dyn.iinet.net.au. [124.169.169.118]) by mx.google.com with ESMTPS id pc6sm13847858pbc.47.2012.07.06.19.27.42 (version=SSLv3 cipher=OTHER); Fri, 06 Jul 2012 19:27:44 -0700 (PDT) Message-ID: <4FF79E9B.8040304@ringerc.id.au> Date: Sat, 07 Jul 2012 10:27:39 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Sylvain CAILLET CC: pgsql-performance@postgresql.org Subject: Re: Create tables performance References: <2ea3ab10-6768-45f2-a748-7f6c94be30fc@zimbra-ne01.network-studio.com> In-Reply-To: <2ea3ab10-6768-45f2-a748-7f6c94be30fc@zimbra-ne01.network-studio.com> Content-Type: multipart/alternative; boundary="------------050105060901010505000907" X-Gm-Message-State: ALoCoQmziUQL+3CYLx2xHY9Dsna1krlMlFTYQSY8MRamqxfR1ANOjLuaBv5KYJgv0RMdR4M1I5wg X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/73 X-Sequence-Number: 47254 This is a multi-part message in MIME format. --------------050105060901010505000907 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 07/06/2012 11:15 PM, Sylvain CAILLET wrote: > Hi to all, > > I run Postgresql 8.3.9 on a dedicated server running with Debian > 5.0.4, a strong bi quad-proc with RAM 16Go. My biggest db contains at > least 100 000 tables. Last time, I started a Java process I use to > make some change on it, it created 170 new tables and it took one full > minute. That is a very long time for such a process on such a server ! If you create and drop a lot of tables, you need to make sure you're vacuuming the pg_catalog tables frequently. Newer versions mostly take care of this for you, but on 8.3 you'll at minimum have to turn autovaccum right up. See what happens if you run in psql, as a Pg superuser (usually the "postgres" account): CLUSTER pg_class_oid_index ON pg_catalog.pg_class; CLUSTER pg_type_oid_index ON pg_catalog.pg_type; CLUSTER pg_attribute_relid_attnam_index ON pg_catalog.pg_attribute; CLUSTER pg_index_indexrelid_index ON pg_catalog.pg_index; I'm guessing you have severe table bloat in your catalogs, in which case this may help. I use CLUSTER instead of VACCUUM FULL because on old versions like 8.3 it'll run faster and sort the indexes for you too. > Do you think there could be some configuration tuning to do to improve > the performance for create tables ? > Or do I have to use tablespaces because 100000 files in a single > folder is a too many for OS ? That won't be a problem unless your OS and file system are truly crap. -- Craig Ringer --------------050105060901010505000907 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 07/06/2012 11:15 PM, Sylvain CAILLET wrote:
Hi to all,

I run Postgresql 8.3.9 on a dedicated server running with Debian 5.0.4, a strong bi quad-proc with RAM 16Go. My biggest db contains at least 100 000 tables. Last time, I started a Java process I use to make some change on it, it created 170 new tables and it took one full minute. That is a very long time for  such a process on such a server !
If you create and drop a lot of tables, you need to make sure you're vacuuming the pg_catalog tables frequently. Newer versions mostly take care of this for you, but on 8.3 you'll at minimum have to turn autovaccum right up.

See what happens if you run in psql, as a Pg superuser (usually the "postgres" account):

  CLUSTER pg_class_oid_index ON pg_catalog.pg_class;
  CLUSTER pg_type_oid_index ON pg_catalog.pg_type;
  CLUSTER pg_attribute_relid_attnam_index ON pg_catalog.pg_attribute;
  CLUSTER pg_index_indexrelid_index ON pg_catalog.pg_index;

I'm guessing you have severe table bloat in your catalogs, in which case this may help. I use CLUSTER instead of VACCUUM FULL because on old versions like 8.3 it'll run faster and sort the indexes for you too.

Do you think there could be some configuration tuning to do to improve the performance for create tables ? 
Or do I have to use tablespaces because 100000 files in a single folder is a too many for OS ?

That won't be a problem unless your OS and file system are truly crap.

--
Craig Ringer

--------------050105060901010505000907--