Limited-Time Offer: Enjoy 50% Savings! - Ends In 0d 00h 00m 00s Coupon code: 50OFF
Welcome to QA4Exam

Free practice questions with explanations

PostgreSQL PGCES-02 Dumps 2026 with Free Practice Questions and Answers

Practise for the PostgreSQL CE 8 Silver exam with 14 original questions, each with an answer and explanation.

Topics: Advanced PostgreSQL Features, Data Definition And Manipulation, Database Administration, High Availability And Disaster Recovery and 3 more.

Includes single answer, multiple answers, dropdown, order list and drag and drop. A new question is added every 15 days.

PGCES-02 Practice Set Details

Exam Code
PGCES-02
Questions On This Page
14
Exam Topics Covered
7 of 7
Question Types
5
Newest Question
New Question
Every 15 days
Full Question Set
142
Certification
PostgreSQL Certified Engineer
14 questions

PostgreSQL PGCES-02 Exam Questions and Answers by Topic

PostgreSQL Fundamentals

2 practice questions on this topicWhat this topic covers

Question 1

Added

Drag And Drop

A reporting service needs results from several PostgreSQL 9.6 query patterns. Match each requirement to the SQL construct that gives the stated behavior.

Drag each item onto its matching target. On a phone: tap an item, then tap a target.

Return rows present in both query results, with duplicates eliminated.
Keep every left-side row, with nulls when no right-side row matches.
Return one row for each distinct grouping key and its aggregate.
Return rows from the first query that are absent from the second query.
LEFT JOIN
INTERSECT
EXCEPT
GROUP BY
Correct answer:
  • Keep every left-side row, with nulls when no right-side row matches. → LEFT JOIN
  • Return rows present in both query results, with duplicates eliminated. → INTERSECT
  • Return one row for each distinct grouping key and its aggregate. → GROUP BY
  • Return rows from the first query that are absent from the second query. → EXCEPT

LEFT JOIN preserves unmatched rows from its left input and fills right-side columns with nulls. INTERSECT returns common rows and removes duplicates unless INTERSECT ALL is specified. GROUP BY forms groups by the selected grouping expressions so aggregates are calculated per group. EXCEPT removes rows found in the second query from the first result. These constructs have distinct row-preservation and set semantics, so substituting one for another would change the requested output.

Question 2

Added

Multiple Answers

A data import writes timestamps supplied as text by several regional systems. The text may include an explicit numeric UTC offset, and the same input must represent the same instant regardless of the session TimeZone. Analysts also need to display values in their own session time zones. Which two design choices correctly support these requirements? (Choose two.)

Correct answer: A, D

A timestamp with time zone value represents an instant; PostgreSQL converts offset-bearing input to that instant and renders it according to the session TimeZone. Explicitly parsing the supplied offset, or applying an explicit zone conversion when necessary, prevents the importing session's settings from changing the meaning. A timestamp without time zone stores a wall-clock value without an instant. PostgreSQL does not preserve the original textual offset as part of timestamptz, and stripping offsets can discard information needed to identify the correct instant.

Data Definition and Manipulation

2 practice questions on this topicWhat this topic covers

Question 3

Added

Single Answer

A migration must add a required `source_system` column to a 600-million-row PostgreSQL 9.6 table. Existing rows should read as `legacy`, new inserts must supply the value, and the migration window is too short for a full table rewrite. The application is already prepared to populate the column on new rows. Which deployment plan best satisfies the constraints while enforcing the requirement for existing data?

Correct answer: D

In PostgreSQL 9.6, adding a column with a non-null default can require rewriting the table, making the staged nullable-column and batched-backfill plan the appropriate low-downtime approach. After the backfill, SET NOT NULL enforces the rule for all rows, while the application supplies values for future inserts. The direct NOT NULL DEFAULT approach risks the prohibited rewrite. A NOT NULL column without a default cannot be added while rows exist. A partial index neither fills missing values nor enforces non-nullability.

Question 4

Added

Single Answer

An order-processing service stores one row per order in PostgreSQL 9.6. The business rule requires exactly one current order per external reference, while allowing the same reference to be reused after the older order is marked archived. Concurrent requests must not create duplicates, and the application cannot serialize requests itself. Which database design is the best fit?

Correct answer: A

A unique partial index enforces uniqueness only among rows satisfying the predicate, so archived orders can retain their references while current orders remain unique. The index enforcement is concurrency-safe, including simultaneous inserts. CHECK constraints cannot reliably enforce cross-row uniqueness. A trigger that performs a separate duplicate lookup can race unless it adds serialization, and the stated non-unique index does not provide that protection. A full unique constraint would prohibit reuse unless archived rows were modified to discard the reference.

SQL Querying and Optimization

2 practice questions on this topicWhat this topic covers

Question 5

Added

Dropdown

An analyst needs one row per customer with the number of paid invoices, including customers with no paid invoices. The query must avoid counting invoices with another status. Complete the SQL by selecting the correct join and aggregate filter.

Choose the correct value for each blank.

SELECT c.customer_id, count(i.invoice_id) FILTER (WHERE i.status = 'paid') AS paid_count FROM customer c invoice i ON i.customer_id = c.customer_id GROUP BY c.customer_id;
Correct answer:

SELECT c.customer_id, count(i.invoice_id) FILTER (WHERE i.status = 'paid') AS paid_count FROM customer c LEFT JOIN invoice i ON i.customer_id = c.customer_id GROUP BY c.customer_id;

LEFT JOIN retains customers that have no matching invoice; their invoice columns are null, and count(invoice_id) returns zero. The FILTER clause counts only rows whose status is paid, without removing customers that have no qualifying invoice. INNER JOIN would omit customers without invoices. CROSS JOIN would create unrelated row combinations, while FULL JOIN would also introduce invoice-only rows that do not represent a customer in the requested result.

Question 6

Added

Single Answer

A PostgreSQL 9.6 reporting query filters a large event table by a timestamp range and a tenant identifier. The table has a B-tree index on `tenant_id` and a separate B-tree index on `event_time`; the query returns a small fraction of rows, but EXPLAIN shows a sequential scan. The planner's row estimates are substantially below the actual count for common tenants, and statistics are several weeks old. The team cannot change the query or add hardware before the report is due. What should the DBA do first?

Correct answer: B

Stale statistics and materially inaccurate cardinality estimates are a direct reason the planner may choose a sequential scan despite selective predicates. ANALYZE refreshes statistics and is the least disruptive first action; the resulting plan can then be evaluated against actual row counts. Hash indexes do not support the required timestamp range comparison. Disabling sequential scans is a diagnostic planner setting, not a sound production fix, and it does not guarantee the desired index plan. CLUSTER rewrites the table and cannot permanently eliminate sequential scans.

Database Administration

2 practice questions on this topicWhat this topic covers

Question 7

Added

Multiple Answers

A PostgreSQL 9.6 server has a large, write-heavy table whose dead tuples are accumulating faster than routine vacuuming can reclaim them. Storage is constrained, and the team must avoid an extended exclusive lock during business hours. They have confirmed autovacuum is enabled and want to make the next maintenance run more aggressive for this table without changing cluster-wide behavior. Which two actions are the best fit? (Choose two.)

Correct answer: B, C

Table storage parameters can tune autovacuum locally: a lower scale factor or threshold causes vacuuming to start with fewer dead tuples, and a lower cost delay lets the worker perform more work before sleeping. Disabling autovacuum would worsen accumulation and remove the requested automatic maintenance. VACUUM FULL takes an access-exclusive lock and is unsuitable for business-hour operation. vacuum_freeze_min_age controls freezing behavior, not the threshold for reclaiming dead tuples.

Question 8

Added

Single Answer

A PostgreSQL 9.6 server is approaching transaction ID wraparound protection thresholds. The monitoring team sees autovacuum activity, but the oldest database's age continues to increase. The cluster has several long-running transactions and one replication slot retaining WAL. The immediate goal is to prevent forced shutdown while identifying the cause, without deleting application data or disabling safety mechanisms. What should the DBA do first?

Correct answer: C

The first step is to identify old transactions that can hold back the global xmin horizon and to assess the oldest database's vacuum and freezing progress. VACUUM freezing is what advances tuples toward safe transaction ID ages; the DBA should preserve the protection mechanisms while removing the actual blockage and ensuring vacuum completes. Raising autovacuum_freeze_max_age delays emergency action rather than resolving risk. A replication slot can retain WAL, but that alone does not prevent tuple freezing. VACUUM FULL does not reset transaction ID age and adds disruptive locking.

Advanced PostgreSQL Features

2 practice questions on this topicWhat this topic covers

Question 9

Added

Single Answer

A billing system records every change to an invoice in an audit table. The audit row must contain both the old and new values, and the same audit behavior must apply to updates issued by application roles as well as by maintenance scripts. The audit function should not be callable directly by clients, and a failure to write the audit record must prevent the invoice update. Which design best meets these requirements?

Correct answer: A

An AFTER UPDATE row trigger can access OLD and NEW for each affected row, and its insert runs in the same transaction as the invoice update. If the audit insert fails, the update statement fails as well. Trigger functions are invoked by triggers rather than directly by ordinary SQL, and revoking EXECUTE prevents direct calls where applicable. A BEFORE trigger can work for auditing, but the proposed direct-call approach is unnecessary and does not satisfy the stated interface. Statement triggers do not have OLD and NEW row variables, and the application-side separate transaction can leave an unaudited update.

Question 10

Added

Single Answer

An operations team wants to install a PostgreSQL extension in a database, but the package files are already installed on the server and the extension requires a privileged installation step. Application developers have database ownership only in a non-production database; they must not gain superuser access. The extension is not marked trusted, and the production change must be repeatable through SQL deployment scripts. What is the best approach?

Correct answer: C

For an extension that is not trusted, CREATE EXTENSION requires superuser privileges, so a controlled superuser deployment is appropriate without granting developers elevated access. Installing package files alone does not register the extension in a database. Database ownership does not override the privilege requirement for an untrusted extension. Changing search_path does not grant privileges, and LOAD loads a library for a session but does not perform extension installation or create its database objects.

High Availability and Disaster Recovery

2 practice questions on this topicWhat this topic covers

Question 11

Added

Order List

A team is configuring a PostgreSQL 9.6 standby on a separate host using streaming replication. The primary uses replication slots, and the standby must begin from a consistent base backup and connect as the dedicated replication user. Arrange the operational steps in the order they must be performed.

Drag the steps into the correct order, or use the arrows.

  1. Run pg_basebackup using the slot and write recovery.conf for streaming.
  2. Start the standby and verify that it reaches streaming state.
  3. Create the replication role and configure primary connection access.
  4. Create a physical replication slot on the primary.
Correct answer:
  1. Create the replication role and configure primary connection access.
  2. Create a physical replication slot on the primary.
  3. Run pg_basebackup using the slot and write recovery.conf for streaming.
  4. Start the standby and verify that it reaches streaming state.

The primary must first accept the replication role's connection, and the physical slot must exist before the backup requests it. pg_basebackup then copies a consistent cluster state while using that slot to retain WAL needed by the standby. The standby can only start replaying and stream after its base files and recovery.conf are in place. Starting first cannot establish a usable standby, and creating the slot after the backup risks missing WAL required during setup.

Question 12

Added

Order List

A PostgreSQL 9.6 administrator must restore a cluster from a base backup and archived WAL to a point just before an accidental transaction. The backup is complete, archive recovery is configured, and the required target timestamp is known. Arrange the recovery actions in the correct order, stopping the server at the target rather than allowing it to promote as a primary beforehand.

Drag the steps into the correct order, or use the arrows.

  1. Start PostgreSQL and verify recovery stops at the requested point.
  2. Stop PostgreSQL and preserve the damaged data directory for investigation.
  3. Restore the base backup into the data directory.
  4. Configure recovery.conf with archive retrieval and the target timestamp.
Correct answer:
  1. Stop PostgreSQL and preserve the damaged data directory for investigation.
  2. Restore the base backup into the data directory.
  3. Configure recovery.conf with archive retrieval and the target timestamp.
  4. Start PostgreSQL and verify recovery stops at the requested point.

The damaged cluster must be stopped before replacing its files, and preserving it supports later investigation. The base backup supplies the starting state. In PostgreSQL 9.6, recovery.conf directs archive retrieval and specifies the recovery target before startup. PostgreSQL then replays WAL until that target and stops recovery according to the configured target action. Starting before configuring recovery would not apply the intended point-in-time recovery settings.

Security

2 practice questions on this topicWhat this topic covers

Question 13

Added

Multiple Answers

A compliance review finds that a PostgreSQL 9.6 application role can read salary data but should not see the salary column in a new reporting workflow. The same role still needs other employee columns, and administrators want the workflow to use a stable database object rather than changing application SQL to enumerate columns. The role must not be able to bypass the restriction by querying the base table. Which two actions meet the requirement? (Choose two.)

Correct answer: C, D

A view can expose only the columns needed by the workflow, while revoking SELECT on the base table prevents the role from bypassing that view with a direct query. PostgreSQL 9.6 supports granting privileges on views separately from privileges on their underlying tables for ordinary view access. Keeping base-table SELECT would leave salary accessible. Row-level security filters rows, not columns, and a DEFAULT expression affects inserted values rather than query visibility.

Question 14

Added

Dropdown

A PostgreSQL 9.6 server accepts remote application connections only from the application subnet. The security team requires password authentication using SCRAM, but the installed PostgreSQL version does not support SCRAM. Complete the authentication rule for the supported password method while restricting access to the specified database, user, and subnet.

Choose the correct value for each blank.

host appdb appuser 10.20.30.0/24
Correct answer:

host appdb appuser 10.20.30.0/24 md5

PostgreSQL 9.6 supports MD5 password authentication through pg_hba.conf, and the host rule limits that method to the named database, role, and subnet. SCRAM support was introduced in later PostgreSQL versions, so it cannot be configured on this server. Trust would allow matching clients to connect without password verification. Peer and ident are not the appropriate password method for this remote TCP host rule.

More Practice Questions

Get the Full PostgreSQL PGCES-02 Dumps as PDF and Practice Test

14 questions are free on this page and the full set has 142. It comes as a PDF and an online practice test, with 90 days of free updates.