Re: Create tables performance

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: Sylvain CAILLET <scaillet(at)alaloop(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Create tables performance
Date: 2012-07-07 02:27:39
Message-ID: 4FF79E9B.8040304@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Nate Allan 2012-07-07 22:35:06 Terrible plan for join to nested union
Previous Message Chris Hanks 2012-07-06 18:32:25 Re: PostgreSQL db, 30 tables with number of rows < 100 (not huge) - the fastest way to clean each non-empty table and reset unique identifier column of empty ones.