Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow schema / table creation in postgres

I have a postgres database with ~65,000 schemas (one-per-customer), each with ~5 - 20 tables. I'm noticing that creating new schemas and tables seems to be slowing down. I'm guessing there might be a system table that's not indexed properly to support this scenario, but calling "EXPLAIN CREATE SCHEMA" throws a syntax error, so I'm at a loss for how to debug this. Any ideas?

EDIT: This is an Amazon RDS database, m4.2xlarge instance w/ high availability, 400 GB of SSD storage.

like image 748
josh Avatar asked Oct 18 '25 16:10

josh


1 Answers

Unless you took special steps, you're storing 325,000 to 1.3 million files in a single directory. Not all filesystems deal gracefully with that many files one directory.

The special steps involve creating tablespaces, and moving tables or indexes using alter table ... set tablespace ....

like image 200
Mike Sherrill 'Cat Recall' Avatar answered Oct 21 '25 07:10

Mike Sherrill 'Cat Recall'



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!