Study guide
7.2 Firestore Data, Indexes, and Transactions
Google Cloud Professional Cloud Developer Exam
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Exam and Compute Platform Decisions
1.1 Current Exam, Sources, and Scenario Method 1.2 Cloud Run Execution and Platform Selection 1.3 GKE Modes and Compute Engine Trade-offs
2 Chapter 2: Container Engineering and API Contracts
2.1 Stateless Microservices and Multi-stage Builds 2.2 Container Hardening, Signals, and Layer Caching 2.3 REST, gRPC, and Protobuf Contracts
3 Chapter 3: gRPC Compatibility and Geographic Routing
3.1 Schema Evolution and gRPC Routing 3.2 Geography, Network Tiers, and Load Balancers 3.3 Serverless NEGs, Sessions, and Edge Controls
4 Chapter 4: API Management and Caching
4.1 API Management & Rate Limiting with Apigee and API Gateway 4.2 Memorystore and Cache Access Patterns 4.3 Cache Invalidation, Capacity, and Failover
5 Chapter 5: Messaging, Task Dispatch, and Orchestration
5.1 Event-Driven Messaging with Cloud Pub/Sub 5.2 Task Queues & Rate Throttling with Cloud Tasks 5.3 Event Routing and Service Orchestration: Eventarc & Cloud Workflows
6 Chapter 6: Resilience and Relational Availability
6.1 Designing Resilient Systems: Circuit Breaking, Retries & Failover 6.2 Cloud SQL Availability and Recovery 6.3 Connection Budgets and Spanner Consistency
7 Chapter 7: Distributed Schemas and NoSQL Data Models
7.1 Spanner Keys, Indexes, and Transactions 7.2 Firestore Data, Indexes, and Transactions 7.3 Bigtable Row Keys and Replication
8 Chapter 8: Object Storage and Application Identity
8.1 Cloud Storage Lifecycle and Signed Access 8.2 Workload Identity and Service Authentication 8.3 Secret Delivery, Rotation, and IAP
9 Chapter 9: Security, Data Integration, and Developer Credentials
9.1 Private Communication, Key Rotation, and Vulnerability Response 9.2 AlloyDB Schemas and BigQuery Ingestion 9.3 CLI Configurations, Local ADC, and Cloud Shell
10 Chapter 10: Managed Development and Automated Tests
10.1 Cloud Workstations and the Container Inner Loop 10.2 Emulating Google Cloud Services & Database Auth Proxies 10.3 Automated Testing Strategies: Unit, Integration, and Mocking
11 Chapter 11: AI Development Tools and Build Pipelines
11.1 AI Coding Assistants, Context, MCP, and Test Review 11.2 Cloud Build Workers and Step Dependencies 11.3 Builders, Substitutions, Triggers, and IAM
12 Chapter 12: Artifact Security and Admission Policies
12.1 Artifact Management and Vulnerability Scanning with Artifact Registry 12.2 Build Provenance and Admission Concepts 12.3 Attestors, Policy Enforcement, and Break-glass
13 Chapter 13: Cloud Run and GKE Deployment Configuration
13.1 Cloud Run Deployment and Scaling Configuration 13.2 Cloud Run CPU, Private Egress, and Secrets 13.3 GKE Workload Controllers and Gateway Routing
14 Chapter 14: Kubernetes Resources, Health, and Progressive Releases
14.1 GKE Resources, OOM Diagnosis, and Autoscaling 14.2 Container Health Probes, Lifecycle Hooks & Graceful Shutdown 14.3 Progressive Delivery: Traffic Splitting, Canary, and Blue/Green Rollouts
15 Chapter 15: Source/Event Deployment and Cloud API Integration
15.1 Source Deployment, Event Receivers, and API Versions 15.2 Client Libraries, Service Enablement, and ADC 15.3 API Responses, Pagination, Caches, and Retries
16 Chapter 16: Tracing, Sampling, and Monitoring
16.1 Trace Context and OpenTelemetry Export 16.2 Custom Spans, Trace Analysis, and Sampling 16.3 Application Metrics, Health Checks & Alerting with Cloud Monitoring
17 Chapter 17: Structured Logs, Routing, and Error Management
17.1 Structured Logs, Trace Correlation, and Queries 17.2 Log Routing, Export Destinations, and Exclusions 17.3 Error Reporting Formats and Regression Handling
18 Chapter 18: Profiling, Generative AI, and Assisted Troubleshooting
18.1 Cloud Profiler Types and Flame Graph Analysis 18.2 Generative AI Integration with the Google Gen AI SDK 18.3 Evidence-Based Troubleshooting with AI Assistance
7.2 Firestore Data, Indexes, and Transactions
Key Takeaways Explain This Topic AI
Collection queries do not recursively download subcollections.
Collection-group scope and the actual filter/order pattern determine required indexes.
Transactions support read-dependent writes; client/database concurrency modes differ.
Last updated: October 2026
NoSQL & Object Storage: Firestore, Bigtable, and Cloud Storage
Cloud-native architectures frequently process unstructured media, real-time hierarchical documents, and high-frequency analytical telemetry that exceed the operational boundaries of traditional relational databases. Google Cloud provides three specialized storage solutions for these workloads: Cloud Firestore for flexible serverless document storage, Cloud Bigtable for massive petabyte-scale wide-column time-series analytics, and Cloud Storage (GCS) for durable, highly available object storage. The Google Cloud Professional Cloud Developer exam tests your ability to engineer optimal row keys, configure transactional concurrency, manage data lifecycles, and implement secure direct client file transfers.
Cloud Firestore: Architecture and Operating Modes
Cloud Firestore is a fully managed, serverless, document-oriented NoSQL database featuring regional or multi-region replication according to database location, strong consistency, and rich querying capabilities.
Operating Modes: Native Mode vs. Datastore Mode
When creating a Firestore database, you must choose between two mutually exclusive operating modes (mode-conversion eligibility is constrained; do not assume an existing populated database can simply be switched):
- Capability Firestore Native Mode Firestore in Datastore Mode
- Data Model Documents, Collections, and Subcollections Entities, Kinds, and Properties
Client Access Web, iOS, Android, Unity SDKs + Server Client Libraries Server Client Libraries only (No web/mobile SDKs)
- Real-Time Sync Supported (Real-time snapshots and listeners) Not supported
- Offline Persistence Automatic offline caching in mobile and web SDKs Not supported
Security Rules Firestore Security Rules based on user identity IAM-based server access; do not confuse this with client Security Rules
Write Throughput Optimized for collaborative web/mobile apps Optimized for massive server-to-server write throughput
Primary Use Cases Mobile, web, gaming, and real-time collaborative state Legacy App Engine Datastore migration, high-throughput server backends
The Document-Collection Model & Shallow Queries
In Firestore Native Mode, data is stored in documents , which are organized into collections . Documents can contain nested fields (primitive types, arrays, maps) and can host nested subcollections . /users (Collection)
- └── user_42 (Document)
- ├── name: "Jane Doe"
- ├── role: "engineer"
- └── /orders (Subcollection)
- └── order_881 (Document)
- ├── item: "Laptop"
- └── total: 1200
Exam Trap: Shallow Queries: In Firestore Native Mode, all queries are shallow . Querying a collection retrieves documents within that specific collection only. It never returns documents located in nested subcollections. If your application queries /users , it receives user documents; it will never download the nested /orders documents. To query documents across all orders subcollections simultaneously, you must use a Collection Group Query , which needs a collection-group-scope index appropriate for its filters and ordering; a simple collection-group query does not always require a composite index.
- Firestore Indexing, Atomic Operations & Security Rules
- Single-Field vs. Composite Indexes
Single-Field Indexes: Firestore automatically maintains ascending and descending indexes for every scalar field in every document, as well as array-contains indexes for array fields. This enables immediate single-clause filtering (e.g., WHERE status == 'active' ).
Index Exemptions: Automatic indexing consumes storage and incurs write latency. For fields that contain large strings, frequently updated counters, or unindexed metadata maps, developers should configure Index Exemptions to reduce storage costs and accelerate write throughput.
Composite Indexes: Complex combinations of filters and ordering can require a composite index; multiple equality filters can sometimes use index merging. When combining equality with inequality operators ( < , <= , > , >= ) or sort orders ( ORDER BY ), Firestore requires a composite index: Query: db.collection('tickets').where('status', '==', 'open').orderBy('priority', 'desc')
Index: tickets [ status: ASC, priority: DESC ] If a composite index is missing, Firestore rejects the query and returns an error containing a direct URL to generate the required index in the Google Cloud Console.
Atomic Operations: Transactions vs. Batched Writes
Feature Firestore Transactions ( runTransaction ) Firestore Batched Writes ( db.batch() )
Atomic Guarantees All-or-nothing atomicity across all operations All-or-nothing atomicity across all operations
Read Operations Supports reads and writes (All reads must precede writes) Write-only (No reads permitted inside the batch)
Concurrency Model Mobile/web SDKs use optimistic concurrency; server clients honor the database concurrency mode, commonly pessimistic in Standard edition. Retryable contention can rerun the transaction callback No read-dependent transaction callback; write requests can still fail and need suitable retry handling
Operation Limit Subject to request-size, time, index, and documented transaction limits Subject to the current API/SDK batch and request-size limits; chunk bulk workloads
Use Case Read-modify-write workflows (e.g., debiting an account balance) Bulk ingestion, mass deletions, multi-document imports // Atomic Transaction Example (All Reads Must Precede Writes)
- await db.runTransaction(async (transaction) => {
- const accountRef = db.collection('accounts').doc('user_123');
- const doc = await transaction.get(accountRef);
- if (!doc.exists) throw new Error("Account does not exist!");
- const currentBalance = doc.data().balance;
- if (currentBalance < 500) throw new Error("Insufficient funds!");
- // Writes occur after all reads are evaluated
- transaction.update(accountRef, { balance: currentBalance - 500 });
- const logRef = db.collection('audit_logs').doc();
- transaction.set(logRef, { user: 'user_123', amount: 500, timestamp: new Date() });
- });
- Firestore Security Rules
When mobile or web applications access Firestore directly using client SDKs, Firestore Security Rules enforce authentication, authorization, and data validation: rules_version = '2';
- service cloud.firestore {
- match /databases/{database}/documents {
- match /users/{userId} {
- allow read, write: if request.auth != null && request.auth.uid == userId;
- match /orders/{orderId} {
- allow read: if request.auth != null && request.auth.uid == userId;
- allow create, update: if request.auth != null && request.auth.uid == userId
- && request.resource.data.total > 0;
- allow delete: if request.auth != null && request.auth.uid == userId;
- }
- }
- }
- }
Official references checked October 18, 2026: Google Cloud 1 .