





















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















































































Question 1. Which PostgreSQL process is primarily responsible for writing dirty buffers from the shared buffer pool to disk? A) autovacuum worker B) background writer C) checkpointer D) walwriter Answer: B Explanation: The background writer periodically writes dirty pages from the shared buffer pool to the operating system cache, reducing checkpoint I/O spikes. Question 2. In PostgreSQL MVCC, what does a tuple’s xmin field represent? A) The transaction that last updated the tuple B) The transaction that inserted the tuple C) The transaction that will delete the tuple D) The transaction that created the table Answer: B Explanation: xmin stores the ID of the transaction that created (inserted) the tuple; it is used to determine visibility for other transactions. Question 3. Which isolation level provides the strongest guarantee against non‑repeatable reads? A) READ COMMITTED B) REPEATABLE READ C) SERIALIZABLE D) READ UNCOMMITTED Answer: C
Explanation: SERIALIZABLE ensures that concurrent transactions behave as if executed sequentially, preventing non‑repeatable reads, phantom rows, and other anomalies. Question 4. What is the purpose of the pg_class system catalog? A) Stores column definitions B) Stores table and index metadata C) Stores user privileges D) Stores function definitions Answer: B Explanation: pg_class contains an entry for each table, index, sequence, view, and toast table, describing storage parameters and relkind. Question 5. Which command updates optimizer statistics for a table? A) VACUUM ANALYZE B) REINDEX C) CLUSTER D) CREATE STATISTICS Answer: A Explanation: VACUUM ANALYZE performs a vacuum and then collects fresh statistics with ANALYZE, helping the planner make better cost estimates. Question 6. When examining an EXPLAIN ANALYZE output, which line indicates that an index‑only scan was used? A) Index Scan using … B) Bitmap Heap Scan on … C) Index Only Scan using …
A) B‑Tree B) GIN C) GiST D) BRIN Answer: B Explanation: GIN indexes efficiently handle many-to-many mappings like the lexemes in a tsvector, making them optimal for full‑text search. Question 10. In PostgreSQL 13, which feature allows a BRIN index to store a summary of values per block range? A) Minmax aggregation B) Bloom filter C) Hyperloglog D) LSM tree Answer: A Explanation: BRIN indexes store the minimum and maximum values for each block range, enabling fast exclusion of irrelevant blocks. Question 11. Which setting controls the amount of memory used by a single sort operation? A) shared_buffers B) work_mem C) maintenance_work_mem D) effective_cache_size Answer: B
Explanation: work_mem is allocated per operation (e.g., sort, hash) and determines how much RAM can be used before spilling to disk. Question 12. What is the effect of setting max_parallel_workers_per_gather to 0? A) Disables parallel query execution B) Allows unlimited parallel workers C) Limits parallel workers to one per query D) Enables only background writer parallelism Answer: A Explanation: Setting the parameter to 0 disables the creation of parallel worker processes for gather nodes, effectively turning off parallel query execution. Question 13. Which of the following is a characteristic of synchronous streaming replication? A) The primary does not wait for any replica acknowledgment B) Transactions may be lost if the replica fails after commit C) The primary waits for at least one synchronous standby to confirm receipt of WAL D) Replication lag is always zero Answer: C Explanation: In synchronous replication, the primary blocks until a configured synchronous standby acknowledges receipt of the WAL record, ensuring durability. Question 14. How does a replication slot prevent WAL segment loss on the primary? A) It forces the primary to archive every WAL segment immediately B) It retains WAL until the standby has consumed it C) It compresses WAL before sending it to the standby
A) trust B) md C) cert D) scram-sha- 256 Answer: C Explanation: The cert method requires the client to present a valid SSL certificate, and the server validates it against trusted CAs. Question 18. What does the pg_verifybackup utility introduced in PostgreSQL 13 do? A) Checks logical replication slot health B) Validates the integrity of a base backup archive C) Performs a quick vacuum on all tables D) Generates a summary of pg_stat_activity Answer: B Explanation: pg_verifybackup reads a backup created by pg_basebackup and verifies its consistency and checksum, ensuring the backup can be restored. Question 19. Which partitioning method is most efficient for a time‑series table with a daily range? A) List partitioning by day name B) Hash partitioning on timestamp C) Range partitioning on the date column D) Subpartitioning by month within year Answer: C Explanation: Range partitioning on a timestamp column allows each day’s data to reside in its own partition, enabling partition pruning for queries that filter by date.
Question 20. When using postgres_fdw, which object defines which tables are available on the remote server? A) FOREIGN SERVER B) USER MAPPING C) FOREIGN TABLE D) EXTENSION postgres_fdw Answer: C Explanation: FOREIGN TABLE objects map remote tables to local names, specifying columns and options for the foreign data wrapper. Question 21. What is the primary cause of transaction ID (XID) wraparound in PostgreSQL? A) Excessive autovacuum activity B) Long‑running transactions preventing XID reuse C) Frequent checkpointing D) High shared_buffers setting Answer: B Explanation: XIDs are 32‑bit values; if old transaction IDs are still considered active (e.g., due to long‑running transactions), wraparound can be delayed, but eventually the counter wraps, requiring a freeze vacuum. Question 22. Which command forces a manual freeze of all tuples in a table? A) VACUUM (FULL) B) VACUUM FREEZE C) REINDEX TABLE D) CLUSTER
B) GiST can index arbitrary data types with custom operators C) GiST is always faster for equality predicates D) GiST cannot be used for range queries Answer: B Explanation: GiST (Generalized Search Tree) is extensible; developers can define operator classes for geometric, full‑text, and other data types, enabling a wide range of query types. Question 26. Which PostgreSQL configuration parameter controls the number of WAL files retained for streaming replication slots? A) wal_keep_segments (deprecated) / wal_keep_size B) max_wal_size C) checkpoint_timeout D) archive_mode Answer: A Explanation: wal_keep_size (or the older wal_keep_segments) ensures a minimum amount of WAL is retained to satisfy standby servers that may fall behind. Question 27. What does the pg_stat_replication view show? A) Statistics about logical replication only B) Current WAL sender processes and their status C) Disk usage of each database D) Lock conflicts on the primary Answer: B Explanation: pg_stat_replication provides information about each WAL sender process, including state, sent LSN, replay LSN, and lag for physical replication.
Question 28. Which of the following is a valid reason to use a partial index? A) To index all columns of a table B) To speed up queries that filter on a specific predicate C) To replace a primary key constraint D) To improve write performance for all inserts Answer: B Explanation: A partial index includes only rows that satisfy a WHERE clause, making it efficient for queries that consistently filter on that predicate. Question 29. In PostgreSQL, what is the purpose of the visibility map? A) Tracks which pages contain dead tuples B) Records which pages are all‑visible to skip heap reads in index‑only scans C) Stores transaction commit timestamps D) Holds the mapping of logical to physical WAL locations Answer: B Explanation: The visibility map marks pages where all tuples are visible to all transactions, allowing index‑only scans to avoid reading the heap. Question 30. Which command can be used to reorganize a heavily bloated table without taking exclusive locks? A) VACUUM FULL B) CLUSTER C) pg_repack D) REINDEX CONCURRENTLY Answer: C
D) It can only be executed by superusers on the primary node Answer: B Explanation: ALTER SYSTEM SET writes the setting to postgresql.auto.conf, which is read on reload, allowing many parameters to be changed without a restart. Question 34. In a high‑availability setup using Patroni, what component monitors the health of the PostgreSQL instance? A) etcd/Consul/Zookeeper consensus store B) pg_rewind C) pg_basebackup D) walreceiver process Answer: A Explanation: Patroni relies on a distributed consensus store (etcd, Consul, or Zookeeper) to store leader election data and monitor node health. Question 35. Which PostgreSQL function returns the current transaction ID? A) txid_current() B) pg_current_xact_id() C) current_xid() D) xid_current() Answer: A Explanation: txid_current() returns the 32‑bit transaction ID of the current transaction, useful for debugging and monitoring. Question 36. What is the effect of setting wal_compression to on in PostgreSQL 13? A) Compresses WAL records before writing them to disk, reducing storage usage
B) Enables network compression for replication streams only C) Forces checkpoint to wait for compression threads D) Disables WAL archiving Answer: A Explanation: When enabled, PostgreSQL compresses WAL records using pglz before writing, decreasing WAL file size at the cost of CPU overhead. Question 37. Which system view provides information about table bloat estimates? A) pg_stat_user_tables B) pg_class C) pg_buffercache D) pgstattuple (extension) Answer: D Explanation: The pgstattuple extension’s functions (e.g., pgstattuple) return live tuple, dead tuple, and free space statistics, helping to assess bloat. Question 38. In the context of PostgreSQL’s autovacuum daemon, what does the “scale factor” parameter control? A) The percentage of dead tuples that triggers a vacuum B) The maximum number of vacuum workers allowed C) The size of the shared buffer pool D) The frequency of checkpoint intervals Answer: A Explanation: autovacuum_vacuum_scale_factor determines the proportion of dead tuples relative to total rows that must be exceeded before autovacuum runs a vacuum on that table.
Explanation: pg_basebackup connects to a running server, streams a consistent file system copy, and can be used for replication or backup purposes. Question 42. In PostgreSQL, which object type can have a “FOR ALL TABLES” publication? A) ROLE B) DATABASE C) PUBLICATION D) SUBSCRIPTION Answer: C Explanation: A PUBLICATION can be defined with FOR ALL TABLES to automatically include every existing and future table in that database. Question 43. What is the primary benefit of using a BRIN index on a large time‑ordered table? A) It provides exact match performance equal to B‑Tree B) It stores a summary per block range, using minimal space C) It automatically partitions the table D) It enables concurrent updates without locking Answer: B Explanation: BRIN indexes store min/max (or other summaries) for each block range, allowing fast exclusion of irrelevant ranges with very low storage overhead. Question 44. Which of the following statements about pg_rewind is correct? A) It can be used to recover from a crash without a base backup B) It synchronizes a diverged standby back to the primary by replaying WAL in reverse C) It copies the entire data directory from primary to standby
D) It only works for logical replication setups Answer: B Explanation: pg_rewind uses WAL to bring a standby that has diverged (e.g., after failover) back in sync with the new primary, without needing a full base backup. Question 45. When creating a table with UNLOGGED, what is the impact on durability? A) All changes are written to WAL as usual B) No WAL is generated, so data is lost on crash or failover C) Only schema changes are logged D) It forces synchronous replication Answer: B Explanation: UNLOGGED tables skip WAL logging, providing faster writes but sacrificing crash‑safety; data is lost if the server crashes. Question 46. Which function can be used to retrieve the current setting of a GUC parameter? A) show_parameter() B) current_setting() C) pg_get_setting() D) get_guc() Answer: B Explanation: current_setting('parameter_name') returns the current value of a configuration parameter, optionally with missing_ok flag. Question 47. In a query plan, what does the “Actual Rows” column represent? A) Estimated number of rows before execution
Question 50. Which command can be used to force a checkpoint immediately? A) SELECT pg_switch_wal(); B) CHECKPOINT; C) VACUUM; D) REINDEX; Answer: B Explanation: The CHECKPOINT command forces PostgreSQL to write all dirty buffers to disk and update the control file, creating a new checkpoint. Question 51. In PostgreSQL 13, which new feature allows parallel vacuuming of indexes? A) Parallel VACUUM (experimental) B) vacuumdb --parallel C) Autovacuum workers now support parallel index cleanup D) No such feature; vacuum is still single‑threaded Answer: D Explanation: As of version 13, VACUUM (including autovacuum) remains single‑threaded; parallelism is not yet supported for vacuum operations. Question 52. Which of the following is true about pg_stat_user_indexes? A) It shows only B‑Tree indexes B) It provides statistics on index scans and tuples fetched per index C) It lists the SQL definitions of indexes D) It records index creation timestamps Answer: B Explanation: pg_stat_user_indexes contains counters like idx_scan, idx_tup_read, and idx_tup_fetch, helping assess index usefulness.
Question 53. What is the default value of max_connections in a fresh PostgreSQL 13 installation? A) 100 B) 200 C) 50 D) 500 Answer: A Explanation: The default max_connections is 100, balancing resource usage for typical workloads. Question 54. Which extension provides row‑level change auditing in PostgreSQL? A) pg_audit (pgaudit) B) pg_stat_audit C) auditlog D) log_user_changes Answer: A Explanation: The pgaudit extension logs detailed session and object‑level activity, useful for compliance auditing. Question 55. When using logical replication, which WAL record type is NOT sent to the subscriber? A) INSERT B) UPDATE C) DELETE D) CHECKPOINT