PostgreSQL Using Too Much Memory
A problem that I’m experiencing with PostgreSQL is that its using too much memory on a local intranet web server. Every time the database is accessed by the PHP script, it creates an instance of Postgres which is about 20 MB in size, and then it seems to stay in memory even though the user has completed their work with the database. I’ve been told that the PHP application is creating persistent connections to the database server, which may be the case but I haven’t examine code deeply enough yet to verify this.
I searched for a way for these processes to time out if no activity occurred within a certain time period. There doesn’t seem to be any options in Postgres for this. There are 20 processes running now on the server (see image below). Postgres has an option to limit connections with max_connection in postgresql.conf. The default value is 100 but I set to 10 to see if this would make a difference. You need to restart the database server whenever you modify its conf file.
I don’t know why Postgres works like this. MySQL is also on the same serve and its doing much more work than Postgres is by serving databases for Joomla, WordPress MU, phpBugTracker, and other applications. MySQL is consistently using about 140 MB of RAM.
I’m still researching ways for Postgres to conserve resources on Fedora.