professional-cloud-data-engineer
Prepare and test your skills
Prepare and test your skills
Worked example. The correct answer is already marked and every option is explained below, so there is nothing to select here. To answer questions yourself, start the free trial.
A data engineering team maintains a Cloud SQL for PostgreSQL instance that serves data models for executive reporting dashboards. During morning peak hours, numerous concurrent dashboard sessions execute complex queries involving large ORDER BY, GROUP BY, and multi-table join operations.
Database logs reveal recurring Out of Memory: Killed process (postgres) errors and connection terminations (terminating connection due to administrator command). Monitoring shows high active session counts and severe RAM saturation.
Which resource configuration adjustment should the data engineer implement to balance query performance and prevent out-of-memory errors?
In PostgreSQL databases, work_mem defines the amount of base memory allocated for internal sort operations (such as ORDER BY and DISTINCT) and hash tables (such as hash joins and hash-based aggregations) before writing temporary data to disk buffers. Unlike global shared memory structures, work_mem is allocated per operation, per backend process, meaning a single complex analytical query containing multiple joins or sorts can allocate multiple multiples of work_mem concurrently.
work_mem rapidly multiplies memory consumption (connections × operations × work_mem), triggering OS-level OOM killer events. Lowering the global default establishes a safe baseline for standard queries.SET work_mem = '...'; locally within their specific session or transaction, isolating high-memory allocations strictly to authorized batch jobs.shared_buffers frees additional unreserved RAM that can be utilized dynamically by backend processes and connection overhead.Setting a conservative baseline with session-level overrides represents standard database optimization. It protects database availability under high connection counts while giving resource-intensive reporting pipelines the flexibility to utilize larger memory allocations safely.
Keep the momentum going with these hand-picked practice scenarios
Want more questions like this?
Get a free certification question every week.