Exam Information
Free practice questions with explanations
PostgreSQL PGCES-02 Practice Questions
Answer a question to see the correct answer and the explanation, or click Show answer. Newest questions first.
- Questions
- 10
- Answered
- 0
- Correct
- 0
- Score
- -
-
1 Question 1 Single choice High Availability and Disaster Recovery
A retail company runs PostgreSQL 9.6 with one primary and two streaming replicas in a single data centre. Their recovery objective is to lose no more than 5 minutes of committed transactions if the primary host fails, and the replicas must not slow commits on the primary when the network to the standby site is congested. The budget excludes any third-party clustering software. The team wants automatic promotion of a replica and continued writes from the application. Which configuration best meets these requirements?
Correct Answer: CExplanationAsynchronous streaming replication keeps commits on the primary independent of standby network latency, while continuous WAL archiving bounds data loss to the archive interval. A monitoring job that promotes a replica with pg_ctl promote gives automatic promotion without extra licensed software. Synchronous replication would make commits wait on a congested link, and it does not perform failover by itself. Turning off synchronous_commit risks losing committed transactions beyond the 5-minute target, and nightly base backups are far too stale. Restoring from archive on demand is a slow manual recovery and misses the automatic promotion requirement.
-
2 Question 2 Drag and drop Security
A healthcare provider must satisfy audit and access rules on its PostgreSQL 13 cluster. The application service account must only connect from the application subnet using certificate-verified TLS, the DBA group must be able to read but not alter the clinical schema, and the security team needs a record of DDL changes made by any session. Match each requirement to the PostgreSQL feature that satisfies it.
Drag each item onto its matching target. On a phone: tap an item, then tap a target.
DBA group may read but never modify clinical tablesConnections from the application subnet must be encrypted and verified against a trusted CARecord of every DDL statement executed by any sessionssl_min_protocol_version set to TLSv1.3pgaudit extension with the DDL audit class enabledhostssl entry in pg_hba.conf using clientcert verify-calog_statement set to all with log rotationPredefined read-only role granted SELECT on the clinical schemaCorrect Answer:- Connections from the application subnet must be encrypted and verified against a trusted CA → hostssl entry in pg_hba.conf using clientcert verify-ca
- DBA group may read but never modify clinical tables → Predefined read-only role granted SELECT on the clinical schema
- Record of every DDL statement executed by any session → pgaudit extension with the DDL audit class enabled
ExplanationRequiring verified client TLS from a specific network is done with a hostssl line in pg_hba.conf that uses clientcert verify-ca, which checks the certificate chain against the configured root CA. Read-only access for the DBA group is a matter of role grants on the schema and tables, not server settings. DDL auditing across sessions is what the pgaudit extension provides through its DDL class. The distractors are real settings but solve different problems: protocol version pins the TLS version without verifying identity, and log_statement all produces noisy logs without a structured DDL audit trail.
-
3 Question 3 Single choice Advanced PostgreSQL Features
A finance team maintains a ledger table where every UPDATE must be rejected, and any attempt to delete a row must instead insert a row into an archive table recording the old values. The application runs on PostgreSQL 12 and uses a role that owns the ledger table, so the owner bypasses row-level security. The team wants the rule enforced in the database regardless of which application code runs. Which approach is correct?
Correct Answer: CExplanationA row-level BEFORE trigger fires for every affected row and runs regardless of who owns the table, so it can raise an error on UPDATE and redirect DELETE into the archive table. Row-level security policies do not apply to the table owner unless FORCE ROW LEVEL SECURITY is set, so option C would not reliably block the owner. Rules rewrite queries and the DO NOTHING rule would silently discard updates rather than enforce a rejection, and rules cannot reliably capture old row values for each deleted row. Revoking privileges from the owner is ineffective, since the owner keeps its implicit rights and the restriction would not be enforced for stored procedures run by that owner either.
-
4 Question 4 Dropdown Database Administration
A DBA is investigating a nightly report that now takes 40 minutes after a bulk load. Autovacuum is enabled, but the table has many dead tuples and planner statistics are stale. The DBA must refresh statistics and reclaim space without locking out readers for long periods. Complete the maintenance statement by selecting the correct values.
Choose the correct value for each blank.
TABLE sales_fact; -- refresh planner statistics, then run sales_fact; -- reclaim dead tuple space without an exclusive lockCorrect Answer:ANALYZE TABLE sales_fact; -- refresh planner statistics, then run VACUUM sales_fact; -- reclaim dead tuple space without an exclusive lock
ExplanationANALYZE collects the table statistics the planner uses to choose join orders and scan types, which is the likely cause of the slow report after a bulk load. A plain VACUUM marks dead tuple space reusable and takes only a SHARE UPDATE EXCLUSIVE lock, so readers and writers continue. VACUUM FULL rewrites the table under an ACCESS EXCLUSIVE lock and would block the reporting workload. CLUSTER and REINDEX also take heavy locks and do not refresh statistics, and TRUNCATE would delete data entirely.
-
5 Question 5 Multiple choice SQL Querying and Optimization
A logistics company's analysts run a query that returns the most recent shipment per customer over a 200-million-row shipments table, filtered by a status column and ordered by shipped_at. EXPLAIN ANALYZE shows a sequential scan followed by a sort. The DBA may only change the query and add indexes that cost little to maintain, because writes are heavy. Which TWO changes are most likely to improve this query? (Choose two.)
Correct Answer: A, DExplanationDISTINCT ON with a matching ORDER BY is the idiomatic PostgreSQL way to pick one row per group, and an index on (customer_id, shipped_at DESC) lets the planner read rows already ordered within each customer. A partial index limited to the filtered status keeps it small and cheap to maintain under heavy writes, matching the constraint. A correlated max subquery executes per row and is typically slower here. Disabling sequential scans globally harms other workloads and violates the scope of the change. Hash indexes cannot support ORDER BY, so they would not help the sort.
-
6 Question 6 Order list Data Definition and Manipulation
A developer must change a production orders table so that a new column order_channel is added with a default and a NOT NULL constraint, without holding an exclusive lock for a long period on a table of 300 million rows running PostgreSQL 14. Arrange the steps in the correct order.
Drag the steps into the correct order, or use the arrows.
- Set the column to NOT NULL after validation confirms no nulls remain
- Update rows in small batches to set order_channel to the default value
- Add the column order_channel as nullable with no default
- Validate the constraint with ALTER TABLE VALIDATE CONSTRAINT
- Set a column default for new rows using ALTER TABLE SET DEFAULT
- Add a CHECK constraint NOT VALID on order_channel IS NOT NULL
Correct Answer:- Add the column order_channel as nullable with no default
- Update rows in small batches to set order_channel to the default value
- Set a column default for new rows using ALTER TABLE SET DEFAULT
- Add a CHECK constraint NOT VALID on order_channel IS NOT NULL
- Validate the constraint with ALTER TABLE VALIDATE CONSTRAINT
- Set the column to NOT NULL after validation confirms no nulls remain
ExplanationAdding a nullable column without a default is a metadata-only change, so it avoids a full table rewrite. Setting the default for future rows is also metadata-only, and batched updates backfill existing rows without one long lock. A NOT VALID check constraint is added quickly, then validated with a lighter lock, and only then is SET NOT NULL safe to apply because PostgreSQL can skip the full scan when a validated CHECK already proves non-nullness. Adding NOT NULL with a default in one statement, or running a single large backfill, would hold locks or generate heavy write load for the whole duration.
-
7 Question 7 Single choice PostgreSQL Fundamentals
A developer stores amounts in a column declared as real and sees totals such as 0.1 + 0.2 returning 0.30000001 in reports for a payments application on PostgreSQL 11. The finance team requires exact decimal results with two fractional digits and no rounding drift across millions of rows. Which change is the most appropriate?
Correct Answer: DExplanationThe numeric type stores exact decimal values, so numeric(12,2) keeps two fractional digits precisely and avoids the binary rounding that real and double precision introduce. Keeping arithmetic in SQL preserves that exactness through aggregation. Double precision is still binary floating point, so rounding only in reports hides the drift rather than eliminating it. The money type is locale-dependent and its formatting is cosmetic and tied to lc_monetary, so it is unsuitable for portable exact arithmetic. Integer cents would work in principle, but it pushes formatting and currency logic into the application, which the scenario did not ask for and makes the schema less self-describing.
-
8 Question 8 Drag and drop Advanced PostgreSQL Features
A platform team packages reusable database logic for several applications on PostgreSQL 15. They want versioned installation and clean upgrades, a set of functions that can be installed into any database, and a procedure that performs multi-statement work with its own transaction control. Match each need to the correct construct.
Drag each item onto its matching target. On a phone: tap an item, then tap a target.
Multi-statement work that commits or rolls back its own transactionsVersioned, installable and upgradable bundle of SQL objectsReusable calculation returning a value inside a queryUser-defined function used in a SELECT listEvent trigger attached to the table DDLStored procedure invoked with CALLMaterialized view refreshed on a scheduleExtension created with CREATE EXTENSION and versioned upgrade scriptsCorrect Answer:- Versioned, installable and upgradable bundle of SQL objects → Extension created with CREATE EXTENSION and versioned upgrade scripts
- Multi-statement work that commits or rolls back its own transactions → Stored procedure invoked with CALL
- Reusable calculation returning a value inside a query → User-defined function used in a SELECT list
ExplanationExtensions package SQL objects with version metadata and update scripts, which is exactly what versioned installation and upgrades require. Procedures invoked with CALL are the construct that can issue COMMIT and ROLLBACK inside their body, unlike functions. Functions are the right tool for values used inside queries. Event triggers respond to DDL events rather than packaging reusable logic, and materialized views store query results rather than providing installable behaviour, so both distractors fit different problems.
-
9 Question 9 Single choice Security
A SaaS vendor runs PostgreSQL 16 for many tenants in one database. Each tenant's application connects with its own role, and rows carry a tenant_id column. A regulator requires that a tenant can never see another tenant's rows, even if an application query omits the tenant filter. The table owner is the migration role that also runs the application's schema upgrades. Which approach meets the requirement?
Correct Answer: CExplanationRow-level security filters rows on every query, so omitting the tenant predicate in application SQL cannot expose other tenants' data. Using a session setting that the application establishes per connection lets one policy serve all tenants. FORCE ROW LEVEL SECURITY is needed because the table owner, here the migration role, would otherwise bypass the policy. Views with filters can be bypassed by querying base tables if privileges are not tightly managed, and they rely on application discipline. A policy using current_user without forcing leaves the owner unrestricted, and per-tenant schemas do not stop access through explicit qualified names when grants overlap.
-
10 Question 10 Multiple choice Database Administration
A DBA on PostgreSQL 15 is handling a production incident. A reporting role complains that its queries are blocked for several minutes, and the application's login role keeps receiving 'too many connections' errors. The DBA wants to diagnose the blocking chain and free capacity without restarting the server or changing role privileges. Which TWO actions are most appropriate? (Choose two.)
Correct Answer: D, EExplanationpg_blocking_pids() combined with pg_stat_activity identifies which backend holds the lock the reporting queries are waiting on, which is the correct first diagnostic step. Terminating the offending backend with pg_terminate_backend() frees the lock without a server restart, provided the work it is doing can safely be rolled back. Restarting the server is disruptive and unnecessary here. Raising max_connections does not require a reload (it needs a restart), and it does not address the blocking. Disabling the idle-in-transaction timeout would make the lock problem worse by letting such sessions hold locks indefinitely.
These are 10 of the 142 questions in the full PGCES-02 pack.
Get All 142 QuestionsGet all 142 questions & answers
Full access options for PostgreSQL PGCES-02
Self-study
PDF Version
- 142 actual exam questions
- Compatible with all devices
- Printable PDF format
- No download limits
- 90 days free updates
- 24/7 customer support
Best value
Bundle Pack
- Discounted PDF + online access
- 142 actual exam questions
- Both PDF and online practice test
- Free 90 days updates
- No download or practice limits
- 24/7 customer support
Exam simulation
Online Practice Test
- 142 actual exam questions
- Actual exam environment
- 90 days free updates
- Browser-based software
- 24/7 customer support
100% Money Back Guarantee
Your success comes first
At DumpsProvider, we give you a 100% money back guarantee on all of our exam dumps. For us, your success is the #1 priority and we are more than confident that our exam material will help you pass the PGCES-02 Exam (PostgreSQL CE 8 Silver) on your very first attempt.
In a rare case, if you fail your exam, we will refund your amount without asking a single question.