Parameter · Resource Usage / Kernel Resources
max_files_per_process
Sets the maximum number of files each server process is allowed to open simultaneously.
- Default:
1000 - Type: integer
- Range: 64 … 2147483647
- Applies: Restart required
In plain words
PostgreSQL stores every table and index in its own files. A backend that touches many of them keeps the files open for speed, up to this many. Beyond that it closes the least recently used one and reopens it later, which costs a little time.
For DBAs and operators
PostgreSQL uses a "virtual file descriptor" cache: it may have thousands of files logically open but only max_files_per_process real kernel descriptors (also bounded by the process's ulimit -n, discovered at startup). Files the postmaster opened before forking are not counted. At startup it checks what is available; too few gives FATAL: insufficient file descriptors available to start server process.
When raising it, raise the OS limit too (LimitNOFILE in the systemd unit, nofile in limits.conf) and remember the system-wide total: processes × this value. Workloads with thousands of partitions or tables per query benefit from higher values (e.g. 4000–10000) because constant close/open shows up as kernel time. If the kernel itself runs out, backends log LOG: out of file descriptors: Too many open files; release and retry; that message means lower this, or raise the OS limits.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then restart the server.