# Free GCDE practice questions

> 10 free GCDE practice questions with the correct answer and an explanation.

Page: https://devopscodelab.com/exams/google-cloud-database-engineer/free-practice-questions/
Practice exams: https://devopscodelab.com/exams/google-cloud-database-engineer/

### Question 1 of 10

A payments API must keep running if a single zone fails, with an RPO of zero and an RTO of a few minutes. The workload is MySQL, fits on one machine, and serves customers from one region only. Budget matters, so the team wants the simplest configuration that meets these targets. What should the database engineer provision?

- A. A Spanner multi-region instance so that writes are committed across regions before being acknowledged to the payments API
- B. A Cloud SQL for MySQL instance with high availability (regional) enabled, which keeps a synchronous standby in another zone
- C. A zonal Cloud SQL instance with automated backups and point-in-time recovery enabled so it can be restored into another zone
- D. A zonal Cloud SQL for MySQL instance with a read replica in a second zone that is promoted manually when the zone fails

**Answer:** B

**Explanation:** A regional (HA) Cloud SQL instance replicates synchronously to a standby in another zone and fails over automatically, giving zero data loss and an RTO of minutes. A read replica is replicated asynchronously, so promoting it can lose recent transactions and needs manual action. A Spanner multi-region instance exceeds the requirement and cost for a single-region MySQL workload. Restoring from backup with PITR takes far longer than a few minutes and is a recovery, not an availability, mechanism.

### Question 2 of 10

A support team already stores ticket text in AlloyDB for PostgreSQL. They want to build retrieval-augmented generation by creating embeddings inside SQL statements and running approximate nearest-neighbor searches over 50 million vectors with low latency, without adding a separate vector database. What should the database engineer implement?

- A. Export the tickets to BigQuery nightly, generate embeddings with ML.GENERATE_EMBEDDING, and use VECTOR_SEARCH from the application
- B. Use the google_ml_integration embedding() function to call a Vertex AI model and create a ScaNN index on the vector column
- C. Store embeddings in a pgvector column without any index, relying on the AlloyDB columnar engine to speed up exact searches
- D. Generate embeddings in a Cloud Run service, store them in Memorystore, and run brute-force similarity in the application

**Answer:** B

**Explanation:** AlloyDB AI lets SQL call Vertex AI embedding models through google_ml_integration and offers the ScaNN index for fast approximate nearest-neighbor search at large scale, all inside the existing database. Moving data to BigQuery adds a pipeline and nightly staleness. A cache with brute-force similarity in the application does not scale to 50 million vectors. Without a vector index every query is an exact scan, and the columnar engine does not accelerate vector distance search.

### Question 3 of 10

An industrial IoT platform ingests about 500,000 sensor readings per second, stores 30 TB of history, and serves queries that fetch the readings of one device over a time range. No multi-row transactions or joins are needed. Which database is the BEST fit?

- A. Cloud SQL for PostgreSQL with a table partitioned by day
- B. Spanner with an interleaved Readings table under a Devices table and secondary indexes on time
- C. Firestore in Native mode with one document per reading and a composite index on device and time
- D. Bigtable with a row key that combines the device ID and a timestamp

**Answer:** D

**Explanation:** Bigtable handles very high write throughput and petabyte-scale time series, and a device-plus-timestamp row key turns per-device range queries into efficient scans. Spanner could store the data but its relational and transactional features add cost the workload does not need. A single Cloud SQL instance cannot sustain this ingest rate or comfortably hold 30 TB. Firestore per-document writes at this rate are costly and not designed for dense time-series scans.

### Question 4 of 10 (choose 2)

A Spanner application shows many ABORTED errors in read-write transactions during peaks. Each transaction reads several rows, calls an external pricing API, and then writes. What should the database engineer recommend? (Choose two.)

- A. Remove primary keys so locks are taken at the table level
- B. Use the client library's transaction runner, which retries aborted work
- C. Switch the transactions to read-only with a strong timestamp
- D. Call the external API before starting the transaction to keep it short
- E. Use partitioned DML for every write within the checkout flow

**Answer:** B, D

**Explanation:** Holding locks while waiting on an external call increases conflicts, so moving the call outside the transaction shortens it, and Spanner client libraries retry aborted transactions automatically. Partitioned DML is for bulk, idempotent changes and is not transactional across rows. Read-only transactions cannot write. Spanner tables require primary keys, and coarser locks would worsen contention.

### Question 5 of 10

An automation script that creates and patches Cloud SQL instances across many projects starts failing with RESOURCE_EXHAUSTED errors from the Cloud SQL Admin API during large rollouts. What should the database engineer do?

- A. Increase the machine type of each instance so the API can process more operations in parallel
- B. Run the rollout from several service accounts at once so each account gets its own project quota
- C. Switch the script to use the Cloud SQL Auth Proxy, which does not consume Admin API quota
- D. Check Admin API quota usage, retry with exponential backoff, and request more quota if needed

**Answer:** D

**Explanation:** RESOURCE_EXHAUSTED indicates an API rate quota, which is handled by checking quota usage, retrying with backoff, and requesting more quota when justified. Instance size does not affect API quotas. The Auth Proxy is for data connections and cannot create or patch instances. Admin API quotas are per project, so splitting calls across service accounts in the same project does not raise the limit.

### Question 6 of 10

A compliance team requires that every SELECT on a table containing card data in Cloud SQL for PostgreSQL is logged with the database user and query text, and that logs are retained centrally. Which approach should the database engineer use?

- A. Turn on the log_statement flag with value all and rely on the default _Default log bucket retention for compliance
- B. Enable Query Insights with query plans sampled at the maximum rate so that every SELECT is captured with its text
- C. Enable Admin Activity audit logs for Cloud SQL, which record every query that users run inside the database instance
- D. Enable pgaudit through the cloudsql.enable_pgaudit flag and route its audit log entries to a dedicated log bucket

**Answer:** D

**Explanation:** pgAudit on Cloud SQL produces database-level audit entries, including statement text and user, which flow into Cloud Audit Logs and can be routed to a dedicated bucket with the needed retention. Admin Activity logs cover API operations such as creating instances, not SQL statements. log_statement=all logs every statement for the whole instance, is noisy, and the default bucket retention is short. Query Insights samples and aggregates queries, so it does not guarantee every statement is recorded.

### Question 7 of 10

An enterprise is migrating an Oracle database to AlloyDB for PostgreSQL. The schema contains hundreds of PL/SQL packages, and the team needs to convert DDL and code, review conversion issues, and then replicate data continuously until cutover. Which approach meets these needs with the LEAST custom tooling?

- A. Database Migration Service with a conversion workspace for schema and code conversion, then a continuous heterogeneous migration job into AlloyDB
- B. Spanner migration tool to convert the Oracle schema, followed by a Spanner-to-AlloyDB export using Dataflow once the conversion is done
- C. Datastream from Oracle to Cloud Storage with a Dataflow template that loads the files and creates PostgreSQL tables from Avro schemas
- D. Oracle Data Pump export to Cloud Storage and pg_restore into AlloyDB after the team manually rewrites the PL/SQL packages

**Answer:** A

**Explanation:** Database Migration Service supports Oracle to AlloyDB and Cloud SQL for PostgreSQL migrations, with conversion workspaces (including Gemini-assisted code conversion) for schema and PL/SQL and continuous CDC replication until promotion. Datastream with Dataflow moves data but converts no code and requires assembling the pipeline. The Spanner migration tool targets Spanner, not AlloyDB. Data Pump files cannot be restored with pg_restore, and manual rewriting is exactly the custom effort to avoid.

### Question 8 of 10

A company wants to move a 2 TB on-premises MySQL 8.0 database to Cloud SQL for MySQL with only a few minutes of downtime. The source can reach Google Cloud through Cloud VPN. Which approach should the database engineer use?

- A. Transfer Appliance shipping of the raw data files, followed by attaching them to the Cloud SQL instance as external storage
- B. mysqldump to Cloud Storage and import during a weekend outage
- C. A Database Migration Service continuous job, promoting the destination when replication lag nears zero
- D. Datastream streaming the binlog into BigQuery, then a scheduled query that loads the data into the Cloud SQL instance

**Answer:** C

**Explanation:** Database Migration Service performs an initial load and continuous binlog-based replication into Cloud SQL, so cutover only requires stopping writes and promoting, which takes minutes. A dump and import means downtime for the full export and import of 2 TB. Datastream to BigQuery targets analytics and has no supported path to write back into Cloud SQL as a migration. Cloud SQL does not attach external data files, and Transfer Appliance does not keep the data in sync.

### Question 9 of 10 (choose 2)

A team wants to test its Spanner disaster recovery plan for logical corruption, such as a bad deployment that rewrites many rows. Which exercises are appropriate? (Choose two.)

- A. Stop one replica region manually to check zero data loss behavior
- B. Restore a recent backup into a new database and time the restore
- C. Change the default leader region and confirm that writes keep working
- D. Read data at a timestamp before a simulated bad change with PITR
- E. Disable the change streams and confirm that writes are blocked

**Answer:** B, D

**Explanation:** Corruption is replicated to every replica, so recovery relies on backups and point-in-time recovery; practicing restores and stale reads validates both procedures and timings. Moving the default leader tests write placement, not recovery from bad data. Customers cannot stop a replica region, and region failures would not undo corruption anyway. Change streams are unrelated to recovery and do not block writes.

### Question 10 of 10

A Firestore database supports a consumer app worldwide and must survive the loss of an entire region without data loss. The database has not been created yet. Which choice satisfies this requirement?

- A. Create a regional database and replicate with Firestore change listeners
- B. Create a regional database and schedule daily backups to another region
- C. Create the database in a multi-region location such as nam5 or eur3
- D. Create a regional database with PITR

**Answer:** C

**Explanation:** A multi-region Firestore location synchronously replicates across regions, so a regional outage causes no data loss, and the location must be chosen at creation. Point-in-time recovery protects against logical errors but stays within the single region. Daily backups permit up to a day of data loss. Change listeners are a client feature, and building replication with them is unreliable and unsupported for DR.

Ready for a timed run? Take the free 15-question GCDE mini exam: https://devopscodelab.com/app/exams/google-cloud-database-engineer/mini/

DevOpsCode Lab is not affiliated with Google Cloud. GCDE and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
