Re: Create tables performance - Mailing list pgsql-performance

From Craig Ringer
Subject Re: Create tables performance
Date
Msg-id 4FF79E9B.8040304@ringerc.id.au
Whole thread Raw
In response to Create tables performance  (Sylvain CAILLET <scaillet@alaloop.com>)
Responses Re: Create tables performance
List 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

pgsql-performance by date:

Previous
From: Chris Hanks
Date:
Subject: 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.
Next
From: Nate Allan
Date:
Subject: Terrible plan for join to nested union