Thomas Carroll <tomfecarroll@xxxxxxxxx> writes: > Postgres version: 10.5. work_mem setting: 4MB, shared_buffers setting: 800 MB, connections typically around 30-40. I imagine you checked this already, but ... what is temp_buffers set to? That constrains the maximum memory used for temporary-table buffers in each process, and an unreasonable setting for it could lead to the described behavior. Another thing to keep in mind with long-lived "temporary" tables is that autovacuum can't do anything with them; so it's incumbent on your application to periodically VACUUM and/or ANALYZE them as needed. Otherwise such tables will bloat, which could contribute to excessive use of temporary-table buffers. regards, tom lane