Re: Create tables performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Thank you all for your help. 

@Jeff : my daemon creates these tables at start time so it doesn't do anything else at the same time. The CPU is loaded between 20% and 25%.
@Richard : Sure the DB number of table is quite big and sure most of them have the same structure, but it's very hard to move it now so I have to deal with it for a while ! 
@Craig : I can't run any of the queries. Fo example, "CLUSTER pg_class_oid_index ON pg_catalog.pg_class;" throws a "ERROR:  "pg_class" is a system catalog" exception. But, using VACUUM FULL, it's done in less than a second. Autovacuum is on but not tuned in postgresql configuration file.

Sylvain Caillet

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



[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux