Slow Site Creation in a Multi-Site Environment

We are experiencing noticeable slowness when creating new sites using the following commands:

bench new-site site_name
bench --site site_name install-app erpnext

Our environment hosts over 500 sites, each created as a separate schema on the same server. During the site creation process, we observed that the following SQL query is being executed and appears to contribute to the delay:

SELECT table_name FROM information_schema.tables WHERE table_schema NOT IN (‘pg_catalog’, ‘information_schema’);

This query seems to be affected by the large number of tables in the system, which has grown to over half a million due to the number of sites.

Please note:

  • All sites run smoothly and perform well after creation.
  • There is currently no need to upgrade the server specifications.

We are looking for:

  • The best configuration, settings, or steps recommended by the community to optimize and speed up the site creation process—especially in environments with a large number of sites.