Open rburghol opened 3 months ago
Try the following:
ALTER SYSTEM SET work_mem = '5GB';
ALTER SYSTEM SET maintenance_work_mem TO '8GB';
ALTER SYSTEM SET shared_buffers = '48GB';
ALTER SYSTEM SET maintenance_work_mem = '9 GB';
ALTER SYSTEM SET effective_cache_size = '96GB';
SELECT pg_reload_conf();
From https://www.enterprisedb.com/postgres-tutorials/how-tune-postgresql-memory
work_mem
:
Setting the correct value of work_mem parameter can result in less disk-swapping, and therefore far quicker queries. We can use the formula below to calculate the optimal
work_mem
value for the database server:Total RAM * 0.25 / max_connections
shared_buffers
The value should be set to 15% to 25% of the machine’s total RAM. For example: if your machine’s RAM size is 32 GB, then the recommended value for shared_buffers is 8 GB. Please note that the database server needs to be restarted after this change.
maintenance_work_mem
: The maintenance_work_mem parameter basically provides the maximum amount of memory to be used by maintenance operations like vacuum, create index, and alter table add foreign key operations.
The default value for this parameter, which is set in postgresql.conf, is: It’s recommended to set this value higher than work_mem; this can improve performance for vacuuming. In general it should be:
Total RAM * 0.05
effective_cache_size (integer)
: The effective_cache_size parameter estimates how much memory is available for disk caching by the operating system and within the database itself. The PostgreSQL query planner decides whether it’s fixed in RAM or not. Index scans are most likely to be used against higher values; otherwise, sequential scans will be used if the value is low.
Recommendations are to set Effective_cache_size at 50% of the machine’s total RAM.
FYI @COBrogan @mwdunlap2004 - The system database settings had ZERO effect (see results above), but after clipping, time to process these basic land segment summaries was cut in half.
It is amazing to think so many of our slow run times can be connected to us just trying to use the entire globe in all of our functions, but it's really good to see that we seem to have a solution to that issue. I wonder how many of our assumptions about run time can be reevaluated based off this, like our statement about st_resample being slow.
@mwdunlap2004 Hundred percent agree. I expect some important improvements across the board.
Also @mwdunlap2004 Without the breakthrough on extents with yesterdays TIFF exports, I'd not have even messed with this, and found the efficiency increase.
Comparison Summary
Time: 65521.824 ms (01:05.522)
33915.735 ms (00:33.916)
Time: 875047.339 ms (14:35.047)
Time: 68054.561 ms (01:08.055)
Time: 1483813.021 ms (24:43.813)
SET work_mem = 'XXmb
;` to change config for current connectionALTER SYSTEM SET work_mem...
to change config semi-permanentlypostgresql.auto.conf
which persists until removed by adminSET...
commands go into effect must callSELECT pg_reload_conf();
ALTER SYSTEM RESET ALL; SELECT pg_reload_conf();
to restore default settings (undoes previousALTER SYSTEM ...
commands)Set Up Base Table and Timer function
Change Working memory
Test with 5-year Sample
5-years, 1 landseg, with clip after resample
daymet
res, then clip to landseg bounds again.st_clip()
is simply to avoid the out of memory error because PRISM extent is wonky.st_resample()
might be more memory intensive that previously thought?Just Clip for testing
Just resample for testing
Two landsegs at the same time
Time: 875047.339 ms (14:35.047)