Performance Tuning Tuning for PostGIS performance is much like tuning for any PostgreSQL workload. The only additional consideration is that geometries and rasters are usually large, so memory-related optimizations generally have more of an impact on PostGIS than other types of PostgreSQL queries. For general details about optimizing PostgreSQL, refer to Tuning your PostgreSQL Server. PostgreSQL configuration can be set at the server level without touching postgresql.conf or postgresql.auto.conf by using the ALTER SYSTEM command. Set work_mem, reload the configuration so new connections use the change, and display the current value. Use SHOW ALL to list all settings. ALTER SYSTEM SET work_mem = '256MB'; SELECT pg_reload_conf(); SHOW work_mem; In addition to the Postgres settings, PostGIS has some custom settings which are listed in .
Startup These settings are configured in postgresql.conf: constraint_exclusion Default: partition This is generally used for table partitioning. The default of "partition" forces the planner to only analyze tables for constraint consideration if they are in an inherited hierarchy and avoids paying the planner penalty otherwise. shared_buffers Default: ~128MB Set to about 25% to 40% of available RAM. On windows you may not be able to set as high. max_worker_processes controls the maximum number of background processes available to the server and therefore also bounds how many workers can participate in parallel queries. Default: 8 Sets the maximum number of background processes that the system can support. This parameter can only be set at server start.
Runtime work_mem - sets the size of memory used for sort operations and complex queries Default: 1-4MB Adjust up for large dbs, complex queries, lots of RAM Adjust down for many concurrent users or low RAM. If you have lots of RAM and few developers: SET work_mem TO '256MB'; maintenance_work_mem - the memory size used for VACUUM, CREATE INDEX, etc. Default: 16-64MB Generally too low - ties up I/O, locks objects while swapping memory Recommend 32MB to 1GB on production servers w/lots of RAM, but depends on the # of concurrent users. If you have lots of RAM and few developers: SET maintenance_work_mem TO '1GB'; max_parallel_workers_per_gather Parallel query support in modern PostgreSQL and PostGIS uses this setting to decide how many workers a plan may request. If set to higher than 0, then some queries such as those involving relation functions like ST_Intersects can use multiple processes and can run more than twice as fast when doing so. If you have a lot of processors to spare, you should change the value of this to as many processors as you have. Also make sure to bump up max_worker_processes to at least as high as this number. Default: 0 Sets the maximum number of workers that can be started by a single Gather node. Parallel workers are taken from the pool of processes established by max_worker_processes. Note that the requested number of workers may not actually be available at run time. If this occurs, the plan will run with fewer workers than expected, which may be inefficient. Setting this value to 0, which is the default, disables parallel query execution.