Docsity

PostgreSQL 12 Professional Practice Exam, Exams of Technology

Toggle sidebar
bg1
PostgreSQL 12 Professional Practice Exam
Question 1. **Which PostgreSQL process is responsible for writing completed
WAL buffers to the WAL file on disk?**
A) Checkpointer
B) WAL Writer
C) Background Writer
D) Autovacuum Worker
Answer: B
Explanation: The WAL Writer process periodically flushes WAL buffers that have
been filled by back‑ends to the WAL segment files, ensuring durability before a
checkpoint.
---
Question 2. **In PostgreSQL 12, which storage structure holds information about
free space within each heap page?**
A) Visibility Map (VM)
B) Free Space Map (FSM)
C) Transaction Log (WAL)
D) TOAST Table
Answer: B
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download PostgreSQL 12 Professional Practice Exam and more Exams Technology in PDF only on Docsity!

Question 1. Which PostgreSQL process is responsible for writing completed WAL buffers to the WAL file on disk? A) Checkpointer B) WAL Writer C) Background Writer D) Autovacuum Worker Answer: B Explanation: The WAL Writer process periodically flushes WAL buffers that have been filled by back‑ends to the WAL segment files, ensuring durability before a checkpoint.


Question 2. In PostgreSQL 12, which storage structure holds information about free space within each heap page? A) Visibility Map (VM) B) Free Space Map (FSM) C) Transaction Log (WAL) D) TOAST Table Answer: B

Explanation: The FSM tracks how much free space is available on each heap page, allowing the planner to locate pages that can accommodate new tuples efficiently.


Question 3. What is the primary purpose of freezing transaction IDs (XIDs) in PostgreSQL? A) To improve query performance B) To prevent XID wraparound causing data loss C) To enable row‑level security D) To compress old rows Answer: B Explanation: Freezing replaces old XIDs with a special “frozen” XID, preventing the 32 ‑bit counter from wrapping around, which would otherwise corrupt visibility information.


Question 4. Which configuration parameter controls the size of each WAL segment file? A) wal_segment_size B) wal_file_size

Question 6. Which file contains the client authentication rules for PostgreSQL? A) postgresql.conf B) pg_hba.conf C) pg_ident.conf D) pg_service.conf Answer: B Explanation: pg_hba.conf defines which authentication method is used for each connection type, database, user, and address combination.


Question 7. Which authentication method in pg_hba.conf sends the password in clear text over the network? A) trust B) md C) password D) scram-sha- 256 Answer: C

Explanation: The password method transmits the password in clear text; it should only be used on trusted networks or with SSL/TLS.


Question 8. Which psql meta‑command lists all tables in the current database schema? A) \dt B) \d+ C) \l D) \da Answer: A Explanation: \dt shows a list of relations of type “table” visible in the search_path.


Question 9. What does the pg_stat_activity view show? A) Disk I/O statistics per table B) Current backend processes and their queries C) Autovacuum activity only

A) Larger shared_buffers allocation B) More accurate planner statistics, potentially longer ANALYZE time C) Faster query execution for all queries D) Decreases autovacuum frequency Answer: B Explanation: Raising default_statistics_target increases the number of histogram bins collected by ANALYZE, improving selectivity estimates but requiring more time and space.


Question 12. Which parameter determines the amount of memory available for sorting operations within a single query? 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 join) and controls how much memory can be used before spilling to disk.

Question 13. Which index type is most suitable for full‑text search on a JSONB column? A) B‑tree B) GIN C) BRIN D) Hash Answer: B Explanation: Generalized Inverted Index (GIN) efficiently indexes composite values like the tokens extracted from JSONB for full‑text search.


Question 14. What is a partial index? A) An index that only stores the first 100 rows of a table B) An index built on a subset of rows defined by a WHERE clause C) An index that is automatically dropped after a transaction D) An index that only works on partitioned tables Answer: B

D) Only on system catalogs Answer: C Explanation: VACUUM FULL rewrites the entire table into a new file, requiring an ACCESS EXCLUSIVE lock to prevent concurrent access.


Question 17. What does the autovacuum_vacuum_scale_factor parameter control? A) Percentage of total rows that must be dead before autovacuum runs a vacuum B) Maximum number of autovacuum workers allowed C) Size of the shared memory used by autovacuum D) Time interval between autovacuum runs Answer: A Explanation: The scale factor is multiplied by the table’s live tuple count; when the number of dead tuples exceeds this threshold, autovacuum triggers a vacuum.


Question 18. Which setting enables WAL archiving for point‑in‑time recovery?

A) archive_mode = on B) wal_level = replica C) max_wal_senders = 5 D) checkpoint_timeout = 5min Answer: A Explanation: archive_mode = on tells PostgreSQL to invoke archive_command for each completed WAL segment, making them available for PITR.


Question 19. During a base backup with pg_basebackup, which option includes the WAL files needed for a consistent backup? A) - X fast B) - X stream C) - R D) - C Answer: B Explanation: -X stream streams WAL data while the base backup is taken, ensuring the backup is consistent without needing a separate WAL archive step.

Answer: B Explanation: Replication slots prevent the primary from recycling WAL files that are still needed by a standby, avoiding data loss.


Question 22. Which tool provides connection pooling for PostgreSQL and works at the protocol level? A) pg_basebackup B) pgBouncer C) pg_dump D) pg_rewind Answer: B Explanation: pgBouncer maintains a pool of server connections and reuses them for client sessions, reducing connection overhead.


Question 23. When configuring SSL for PostgreSQL, which parameter enforces that all client connections must use SSL? A) ssl = on B) ssl_prefer_server_ciphers = on

C) ssl_cert_file = 'server.crt' D) ssl_enforce = true Answer: A Explanation: Setting ssl = on enables SSL; combined with hostssl entries in pg_hba.conf, it forces SSL for matching connections.


Question 24. Which command grants SELECT privilege on all tables in schema public to role analyst? A) GRANT SELECT ON ALL TABLES IN SCHEMA public TO analyst; B) GRANT SELECT TO analyst ON SCHEMA public; C) ALTER ROLE analyst SET default_privileges = SELECT; D) REVOKE ALL FROM analyst; Answer: A Explanation: The GRANT SELECT ON ALL TABLES IN SCHEMA public TO analyst; statement grants the desired privilege on existing tables.


Question 27. What is the default procedural language installed in a fresh PostgreSQL 12 cluster? A) plpythonu B) plperl C) plpgsql D) plv Answer: C Explanation: plpgsql is bundled and installed by default, enabling stored procedures and functions written in PL/pgSQL.


Question 28. Which partitioning method in PostgreSQL 12 distributes rows based on a hash of a column value? A) RANGE PARTITIONING B) LIST PARTITIONING C) HASH PARTITIONING D) SUBPARTITIONING

Answer: C Explanation: Hash partitioning creates partitions by applying a hash function to the partition key, distributing rows evenly.


Question 29. When a table is partitioned by RANGE on a timestamp column, which clause is used to create a new partition covering future dates? A) CREATE TABLE ... PARTITION OF parent FOR VALUES FROM (...) TO (...); B) ALTER TABLE parent ATTACH PARTITION new_part; C) CREATE PARTITION new_part OF parent DEFAULT; D) INSERT INTO parent VALUES (...); Answer: A Explanation: The CREATE TABLE ... PARTITION OF parent FOR VALUES FROM (...) TO (...); syntax defines a new range partition.


Question 30. Constraint exclusion works best with which type of partitioning? A) HASH

Question 32. What is the purpose of a foreign key with ON DELETE CASCADE? A) Prevents deletion of referenced rows B) Automatically deletes referencing rows when the parent row is deleted C) Logs deletions to a audit table D) Defers constraint checking until commit Answer: B Explanation: ON DELETE CASCADE propagates the delete operation to child rows, maintaining referential integrity automatically.


Question 33. Which command moves a table to a different tablespace? A) ALTER TABLE mytable SET TABLESPACE fastspace; B) MOVE TABLE mytable TO fastspace; C) ALTER TABLESPACE fastspace OWNER TO mytable; D) REINDEX TABLE mytable TABLESPACE fastspace; Answer: A Explanation: ALTER TABLE mytable SET TABLESPACE fastspace; relocates the table’s physical files to the specified tablespace.

Question 34. Which window function returns the rank of the current row within its partition, with gaps for ties? A) ROW_NUMBER() B) RANK() C) DENSE_RANK() D) NTILE() Answer: B Explanation: RANK() assigns the same rank to tied rows and leaves gaps in the ranking sequence.


Question 35. In a recursive CTE, which keyword indicates the base case? A) UNION ALL B) RECURSIVE C) SELECT ... FROM ... WHERE ... D) WITH RECURSIVE