Which of the following best describes the effect of increasing work_mem in PostgreSQL?
Think about what happens when PostgreSQL sorts or hashes data during a query.
work_mem sets the amount of memory used for internal sort operations and hash tables before writing to disk. Increasing it can reduce disk I/O for large operations.
What does the effective_cache_size setting in PostgreSQL represent?
Consider how PostgreSQL guesses if data is likely cached in memory.
effective_cache_size tells the planner how much memory is available for caching data, helping it decide whether to use index scans or sequential scans.
Given the following PostgreSQL configuration and query, what will be the output of EXPLAIN ANALYZE regarding sort method?
SET work_mem = '64kB'; EXPLAIN ANALYZE SELECT * FROM large_table ORDER BY column1;
SET work_mem = '64kB'; EXPLAIN ANALYZE SELECT * FROM large_table ORDER BY column1;
Think about what happens when work_mem is too small for sorting large data.
With a small work_mem, PostgreSQL cannot sort all data in memory and uses disk-based external merge sort, which is slower.
Which of the following commands correctly sets effective_cache_size to 4GB in PostgreSQL?
Remember the syntax for persistent configuration changes in PostgreSQL.
ALTER SYSTEM SET is the correct way to persistently set configuration parameters like effective_cache_size. Values must be quoted with units.
You have a PostgreSQL server with 32GB RAM and expect up to 20 concurrent queries, each performing multiple sorts. Which work_mem setting is most appropriate to avoid memory exhaustion while allowing efficient sorting?
Calculate memory usage as work_mem * sorts per query * concurrent queries.
Setting work_mem too high risks exhausting RAM when many queries run concurrently. 100MB balances memory use and performance for 20 concurrent queries with multiple sorts.