Docsity

PrepIQ Certified PostgreSQL Professional Ultimate Exam, Exams of Technology

Toggle sidebar
bg1
PrepIQ Certified PostgreSQL
Professional Ultimate Exam
**Question 1.** Which PostgreSQL storage parameter controls the amount of
data that can be stored in a page before a new page is allocated?
A) fillfactor
B) autovacuum_vacuum_scale_factor
C) maintenance_work_mem
D) work_mem
Answer: A
Explanation: fillfactor defines the percentage of a page to be filled with data,
leaving space for future updates and reducing page splits.
**Question 2.** In PostgreSQL, what is the default isolation level for a
transaction?
A) READ UNCOMMITTED
B) READ COMMITTED
C) REPEATABLE READ
D) SERIALIZABLE
Answer: B
Explanation: PostgreSQL defaults to READ COMMITTED, meaning each query sees
a snapshot of data committed before the query began.
**Question 3.** Which command creates a new tablespace that stores its data in
the directory /var/lib/pgdata/tbs1?
A) CREATE TABLESPACE tbs1 LOCATION '/var/lib/pgdata/tbs1';
B) CREATE DATABASE tbs1 LOCATION '/var/lib/pgdata/tbs1';
C) ALTER SYSTEM SET tablespace_directory = '/var/lib/pgdata/tbs1';
D) CREATE SCHEMA tbs1 LOCATION '/var/lib/pgdata/tbs1';
Answer: A
Explanation: CREATE TABLESPACE defines a logical storage area and requires a
file system path via the LOCATION clause.
**Question 4.** Which PostgreSQL data type is best suited for storing a monetary
value with high precision and a fixed fractional part?
A) numeric(12,2)
B) real
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

Partial preview of the text

Download PrepIQ Certified PostgreSQL Professional Ultimate Exam and more Exams Technology in PDF only on Docsity!

Professional Ultimate Exam

Question 1. Which PostgreSQL storage parameter controls the amount of data that can be stored in a page before a new page is allocated? A) fillfactor B) autovacuum_vacuum_scale_factor C) maintenance_work_mem D) work_mem Answer: A Explanation: fillfactor defines the percentage of a page to be filled with data, leaving space for future updates and reducing page splits. Question 2. In PostgreSQL, what is the default isolation level for a transaction? A) READ UNCOMMITTED B) READ COMMITTED C) REPEATABLE READ D) SERIALIZABLE Answer: B Explanation: PostgreSQL defaults to READ COMMITTED, meaning each query sees a snapshot of data committed before the query began. Question 3. Which command creates a new tablespace that stores its data in the directory /var/lib/pgdata/tbs1? A) CREATE TABLESPACE tbs1 LOCATION '/var/lib/pgdata/tbs1'; B) CREATE DATABASE tbs1 LOCATION '/var/lib/pgdata/tbs1'; C) ALTER SYSTEM SET tablespace_directory = '/var/lib/pgdata/tbs1'; D) CREATE SCHEMA tbs1 LOCATION '/var/lib/pgdata/tbs1'; Answer: A Explanation: CREATE TABLESPACE defines a logical storage area and requires a file system path via the LOCATION clause. Question 4. Which PostgreSQL data type is best suited for storing a monetary value with high precision and a fixed fractional part? A) numeric(12,2) B) real

Professional Ultimate Exam

C) double precision D) integer Answer: A Explanation: numeric (or decimal) stores exact numbers with user-defined precision and scale, ideal for money. Question 5. What does the PostgreSQL function pg_total_relation_size('my_table') return? A) Size of the table’s data only B) Size of the table’s indexes only C) Combined size of the table, its indexes, and TOAST data D) Size of the table’s WAL files Answer: C Explanation: pg_total_relation_size includes the main heap, all associated indexes, and any TOAST tables. Question 6. Which of the following is NOT a valid PostgreSQL index type? A) B-tree B) GiST C) R-tree D) GIN Answer: C Explanation: PostgreSQL supports B-tree, GiST, GIN, SP-GiST, and BRIN indexes; R-tree is not a native type. Question 7. When using logical replication, which object must be created on the publisher to define what changes are sent? A) Publication B) Subscription C) Replication slot D) WAL archiving rule Answer: A

Professional Ultimate Exam

Question 11. What is the purpose of the pg_hba.conf file? A) Define database users and passwords B) Configure host-based authentication rules C) Set replication slots D) Store server logs Answer: B Explanation: pg_hba.conf controls which clients can connect, which authentication method is used, and which databases they can access. Question 12. Which of the following statements about the TOAST mechanism is TRUE? A) TOAST stores large values in a separate table automatically. B) TOAST is a user-defined index type. C) TOAST compresses only numeric columns. D) TOAST is only available in PostgreSQL 15 and later. Answer: A Explanation: TOAST (The Oversized-Attribute Storage Technique) automatically moves large field values to auxiliary tables. Question 13. Which command creates a read-only replica using streaming replication? A) CREATE REPLICA myreplica FROM master; B) pg_basebackup -D /var/lib/pgsql/data -X stream -R C) SELECT pg_start_backup('label'); D) ALTER SYSTEM SET replica_mode = 'read-only'; Answer: B Explanation: pg_basebackup with the - R option creates a recovery.conf (or standby.signal) for streaming replication. Question 14. Which function returns the current transaction ID? A) txid_current() B) pg_transaction_timestamp()

Professional Ultimate Exam

C) current_timestamp D) pg_backend_pid() Answer: A Explanation: txid_current() yields the 64-bit transaction identifier of the current transaction. Question 15. In PostgreSQL, what does the VACUUM command accomplish? A) Rewrites the entire database file to a new location B) Removes dead tuples and updates visibility information C) Defragments the file system on disk D) Increases the size of shared_buffers Answer: B Explanation: VACUUM reclaims space occupied by dead rows and updates the MVCC visibility map. Question 16. Which of the following is a valid way to add a column with a default value without rewriting the whole table? A) ALTER TABLE t ADD COLUMN c int DEFAULT 0; B) ALTER TABLE t ADD COLUMN c int NOT NULL DEFAULT 0; C) ALTER TABLE t ADD COLUMN c int; UPDATE t SET c = 0; D) All of the above Answer: B Explanation: Since PostgreSQL 11, adding a NOT NULL column with a constant default is a metadata-only operation; simple defaults without NOT NULL still rewrite the table. Question 17. What does the pg_stat_activity view show? A) Current locks held by each backend B) Active queries, their state, and start time per session C) Disk usage per table D) Replication lag in bytes Answer: B

Professional Ultimate Exam

Question 21. Which PostgreSQL data type can store arbitrary JSON data while preserving the original text? A) jsonb B) json C) text D) xml Answer: B Explanation: json stores the exact text representation; jsonb parses and stores a binary format. Question 22. What is the effect of setting synchronous_commit = off for a session? A) Transactions are never written to WAL. B) Transactions are committed without waiting for WAL flush, improving performance but risking data loss. C) The server disables synchronous replication. D) All queries run in autocommit mode. Answer: B Explanation: Setting synchronous_commit to off allows the transaction to be considered committed before the WAL is flushed to disk. Question 23. Which of the following statements about PostgreSQL’s EXCLUDE constraint is correct? A) It only works with B-tree indexes. B) It enforces uniqueness across multiple columns with a custom operator class. C) It can be used to prevent overlapping time intervals. D) It replaces primary key constraints. Answer: C Explanation: EXCLUDE constraints can enforce arbitrary exclusion rules, commonly used for range types to prevent overlapping periods. Question 24. Which command can be used to change the owner of a table without moving data? A) ALTER TABLE mytable OWNER TO new_user;

Professional Ultimate Exam

B) REASSIGN OWNED BY old_user TO new_user; C) GRANT ALL ON mytable TO new_user; D) UPDATE pg_class SET relowner = …; Answer: A Explanation: ALTER TABLE … OWNER TO changes the table’s ownership metadata. Question 25. In PostgreSQL, which function returns the number of rows affected by the last command? A) FOUND B) GET DIAGNOSTICS row_count; C) pg_affected_rows() D) SELECT ROW_COUNT(); Answer: A Explanation: FOUND is a boolean that is true if the last SQL command affected at least one row; to get the exact count, GET DIAGNOSTICS is used, but among options FOUND is the closest. Question 26. Which of the following is a valid way to create a materialized view that automatically refreshes every hour? A) CREATE MATERIALIZED VIEW mv AS SELECT …; CREATE EVENT TRIGGER hourly_refresh ON SCHEDULE ‘1 hour’ EXECUTE FUNCTION refresh_mv(); B) CREATE MATERIALIZED VIEW mv AS SELECT … WITH DATA; CREATE EXTENSION pg_cron; SELECT cron.schedule('hourly_refresh','0 * * * *','REFRESH MATERIALIZED VIEW mv'); C) CREATE VIEW mv AS SELECT …; ALTER VIEW mv SET (refresh_interval = '1h'); D) Materialized views cannot be refreshed automatically. Answer: B Explanation: pg_cron (or pgAgent) can schedule a REFRESH MATERIALIZED VIEW command; PostgreSQL does not have built-in periodic refresh.

Professional Ultimate Exam

A) SIGNAL

B) RAISE EXCEPTION 'msg'; C) THROW 'msg'; D) ERROR 'msg'; Answer: B Explanation: RAISE EXCEPTION is the PL/pgSQL construct for raising user-defined errors. Question 31. Which command can be used to change the default tablespace for a newly created database? A) ALTER DATABASE mydb SET default_tablespace = 'tbs1'; B) CREATE DATABASE mydb TABLESPACE tbs1; C) SET default_tablespace = 'tbs1'; D) UPDATE pg_database SET dattablespace = …; Answer: B Explanation: CREATE DATABASE … TABLESPACE specifies the tablespace that will store the database’s default objects. Question 32. Which of the following is true about PostgreSQL’s pg_dump utility when used with the - Fc option? A) It creates a plain-text SQL script. B) It produces a custom-format archive that can be restored selectively. C) It streams data directly to another server. D) It only dumps schema, not data. Answer: B Explanation: - Fc creates a custom, non-plain format that pg_restore can use to restore specific objects. Question 33. Which PostgreSQL configuration parameter controls how often the autovacuum launcher wakes up to check tables? A) autovacuum_naptime B) autovacuum_max_workers C) autovacuum_vacuum_threshold

Professional Ultimate Exam

D) autovacuum_analyze_scale_factor Answer: A Explanation: autovacuum_naptime defines the sleep interval between autovacuum cycles. Question 34. What is the effect of setting default_statistics_target to a higher value? A) Increases the size of the shared_buffers cache. B) Improves query planner’s statistics at the cost of longer ANALYZE time. C) Reduces the number of connections allowed. D) Disables parallel query execution. Answer: B Explanation: Higher statistics target means ANALYZE collects more sample rows, giving the planner better cardinality estimates. Question 35. Which of the following is a valid way to enforce row-level security on a table? A) ALTER TABLE mytable ENABLE ROW LEVEL SECURITY; CREATE POLICY mypolicy ON mytable FOR SELECT USING (owner_id = current_user_id()); B) GRANT SELECT ON mytable TO PUBLIC; C) CREATE TRIGGER check_rls BEFORE SELECT ON mytable … D) SET row_security = on; Answer: A Explanation: Row-level security (RLS) is enabled with ALTER TABLE … ENABLE ROW LEVEL SECURITY and policies are defined with CREATE POLICY. Question 36. Which PostgreSQL feature allows you to store and query time-series data efficiently? A) Foreign Data Wrapper (FDW) B) TimescaleDB extension C) pg_partman D) pgcrypto Answer: B

Professional Ultimate Exam

Question 40. In PostgreSQL, which function can be used to generate a series of timestamps at 15-minute intervals between two dates? A) generate_series('2024-01-01'::timestamp, '2024-01-02'::timestamp, interval '15 minutes') B) series_timestamp('2024-01-01','2024-01-02',15) C) date_range('2024-01-01','2024-01-02',15) D) SELECT * FROM timestamps WHERE interval = '15 minutes'; Answer: A Explanation: generate_series works with timestamp and interval arguments to produce sequential timestamps. Question 41. Which of the following statements about PostgreSQL’s pg_hint_plan extension is TRUE? A) It allows you to embed optimizer hints directly in SQL comments. B) It replaces the built-in query planner. C) It only works with GIN indexes. D) It is part of the core distribution. Answer: A Explanation: pg_hint_plan reads specially formatted comments (e.g., /*+ SeqScan(t) */) to influence the planner. Question 42. Which of the following is the correct syntax to create a foreign data wrapper for a MySQL server? A) CREATE SERVER mysql_svr FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host '10.0.0.5', port '3306'); B) CREATE FOREIGN DATA WRAPPER mysql_fdw HANDLER mysql_handler; C) CREATE EXTENSION mysql_fdw; CREATE SERVER mysql_svr FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host '10.0.0.5', port '3306'); D) CREATE FDW mysql_fdw; Answer: C Explanation: First install the extension, then CREATE SERVER with the foreign data wrapper name and connection options.

Professional Ultimate Exam

Question 43. Which PostgreSQL function returns the current transaction’s “snapshot” identifier? A) txid_current_snapshot() B) pg_current_snapshot() C) current_snapshot() D) txid_snapshot() Answer: A Explanation: txid_current_snapshot() returns a text representation of the transaction snapshot used for consistent reads. Question 44. What is the default value of max_wal_size in PostgreSQL 14? A) 1 GB B) 2 GB C) 4 GB D) 10 GB Answer: C Explanation: PostgreSQL 14 sets max_wal_size to 4 GB by default, governing how much WAL can be retained before a checkpoint. Question 45. Which of the following is a valid way to temporarily disable autovacuum for a specific table? A) ALTER TABLE mytable SET (autovacuum_enabled = false); B) SET autovacuum = off; C) ALTER SYSTEM SET autovacuum = false; D) UPDATE pg_class SET reloptions = '{autovacuum_enabled=false}' WHERE relname='mytable'; Answer: A Explanation: Table-level storage parameters can be set with ALTER TABLE … SET (autovacuum_enabled = false). Question 46. Which PostgreSQL data type is best suited for storing IPv4 and IPv6 addresses with built-in operators? A) inet B) cidr

Professional Ultimate Exam

Explanation: EXCLUSIVE UPDATE is not a defined lock mode; the correct modes include ACCESS SHARE, ROW SHARE, ROW EXCLUSIVE, SHARE UPDATE EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE, EXCLUSIVE, and ACCESS EXCLUSIVE. Question 50. Which command can be used to list all installed extensions in a PostgreSQL database? A) \dx B) SELECT * FROM pg_extension; C) SHOW extensions; D) Both A and B Answer: D Explanation: \dx in psql and SELECT * FROM pg_extension both return the list of installed extensions. Question 51. In PostgreSQL, which clause can be used to limit the number of rows returned by a query without sorting? A) LIMIT n B) FETCH FIRST n ROWS ONLY C) TOP n D) Both A and B Answer: D Explanation: Both LIMIT and FETCH FIRST are supported SQL syntax for row limiting. Question 52. Which of the following statements about the pg_buffercache module is true? A) It provides a view of the shared buffer contents for diagnostic purposes. B) It is required for logical replication. C) It stores WAL records in memory. D) It automatically compresses cached pages. Answer: A Explanation: pg_buffercache exposes the contents of shared buffers, useful for debugging cache usage.

Professional Ultimate Exam

Question 53. Which of the following is the correct way to create a function that returns a set of rows in PL/pgSQL? A) CREATE FUNCTION get_users() RETURNS SETOF users AS $$ … $$ LANGUAGE plpgsql; B) CREATE FUNCTION get_users() RETURNS TABLE(id int, name text) AS $$ … $$ LANGUAGE sql; C) Both A and B are valid. D) Neither A nor B; functions cannot return sets. Answer: C Explanation: Both syntaxes are valid; SETOF returns rows of an existing type, while RETURNS TABLE defines column names and types. Question 54. Which of the following is a recommended practice for reducing lock contention on a heavily updated table? A) Increase shared_buffers to 8 GB. B) Use a higher isolation level. C) Partition the table by time or key. D) Disable autovacuum. Answer: C Explanation: Partitioning spreads writes across multiple child tables, reducing contention on a single heap. Question 55. What does the PostgreSQL configuration parameter effective_io_concurrency control? A) Number of parallel workers for query execution. B) Maximum number of concurrent disk I/O operations for background processes (e.g., autovacuum). C) Size of the I/O buffer pool. D) Number of simultaneous client connections. Answer: B Explanation: effective_io_concurrency sets the number of concurrent I/O requests allowed for background workers. Question 56. Which of the following statements about PostgreSQL’s “hot standby” mode is FALSE?

Professional Ultimate Exam

D) json_populate_record() Answer: A Explanation: json_array_elements expands a JSON array to a set of JSON values, which can be further processed. Question 60. Which of the following statements about the pg_stat_user_tables view is correct? A) It shows only tables owned by the current user. B) It includes statistics such as sequential scans, index scans, and tuples inserted. C) It tracks per-column statistics. D) It is only available in PostgreSQL 13 and later. Answer: B Explanation: pg_stat_user_tables provides per-table statistics for tables owned by the user, including scans and tuple counts. Question 61. Which of the following is a valid way to enable parallel query execution for a specific query? A) SET max_parallel_workers_per_gather = 4; SELECT … B) ALTER DATABASE mydb SET parallel_leader_participation = on; C) SELECT /*+ Parallel(4) */ … D) Both A and C (using pg_hint_plan) Answer: D Explanation: Setting the GUC or using pg_hint_plan comments can influence parallelism. Question 62. Which of the following is the correct way to add a comment to a column in PostgreSQL? A) COMMENT ON COLUMN mytable.mycol IS 'User age'; B) ALTER COLUMN mycol COMMENT 'User age'; C) SET COMMENT mycol = 'User age'; D) UPDATE pg_description SET description='User age' WHERE objoid = 'mytable'::regclass; Answer: A

Professional Ultimate Exam

Explanation: COMMENT ON COLUMN … IS adds a descriptive comment stored in pg_description. Question 63. Which PostgreSQL feature allows you to store data on remote servers as if they were local tables? A) Foreign Data Wrapper (FDW) B) Logical replication C) pg_dump D) Table inheritance Answer: A Explanation: FDWs provide a standardized API to access external data sources. Question 64. Which of the following statements about the PostgreSQL configuration parameter wal_level is TRUE? A) Setting wal_level to minimal disables point-in-time recovery. B) wal_level = replica is required for streaming replication and logical replication. C) wal_level = archive enables archiving of WAL files automatically. D) wal_level is ignored in PostgreSQL 12 and later. Answer: B Explanation: wal_level = replica (or higher) ensures enough information is written to WAL for streaming and logical replication. Question 65. Which of the following is the correct syntax to create a partitioned table by list on a column region? A) CREATE TABLE sales (id int, region text, amount numeric) PARTITION BY LIST (region); B) CREATE TABLE sales PARTITION OF region (id int, amount numeric); C) CREATE TABLE sales (id int, region text, amount numeric) LIST PARTITION BY region; D) CREATE PARTITIONED TABLE sales BY LIST (region) (id int, amount numeric); Answer: A Explanation: The PARTITION BY LIST clause follows the column list in the CREATE TABLE statement.