Firestore Native mode meets immediate, sortable, schemaless purchase queries
Short answer
A Firestore in Native mode stores varied purchase document formats, sorts on indexed fields, and returns records with strong consistency immediately after submission.
Question
Key Takeaways
Firestore in Native mode satisfies immediate post-write queries, multi-field sorting, and heterogeneous record formats in one document store. It wins because Native mode reads are strongly consistent and indexed, unlike Datastore mode's eventually consistent global queries. Cloud Storage cannot filter or sort object contents, and Cloud SQL forces a fixed schema with instance-level scale limits.
Expert Analysis
A. Firestore provides scalable NoSQL document database for real-time purchase history queries. Cloud SQL (B) has scale limits. Bigtable (C) is for time-series/analytical, not user-focused queries. Cloud Spanner (D) is overkill for simple purchase history.
The deciding constraint is the first one: purchases must be queryable immediately after submission. Firestore Native mode answers reads from a local document cache and commits to a strongly consistent backend before acknowledging the write, so a read issued right after the submission returns the record with no replication lag. That is exactly the behavior customers need when they refresh an order history page seconds after buying.
Option A satisfies all three requirements at once. Native mode Firestore is a document database, so each purchase can be a document whose fields differ from another customer's record — different payment methods, gift-receipt flags or line-item shapes coexist in one collection without a fixed schema. It also supports single-field and composite index-backed sorting, so purchases can be ordered by date, amount, or merchant. And because documents are strongly consistent on read, "immediately after submission" holds.
Option B, Cloud Storage with an object read, fails on the queryability requirement. Cloud Storage stores opaque blobs addressed by object name; reading an object returns bytes, not a set of records filtered or sorted by field. Even if each purchase were serialized as a JSON object, sorting "on a variety of fields" would require listing objects and parsing them client-side, and there is no filter predicate over object contents. Cloud Storage also offers no immediate, per-record consistency guarantee for field-level queries of this kind.
Option C, Cloud SQL with a SQL SELECT, fails the schema requirement as phrased and is weak on the first. A relational table has a fixed column set, so "distinct record formats stored at the same time" forces either nullable columns, a JSON column with no indexing, or an EAV pattern — none of which the option describes. More importantly, the reference notes Cloud SQL's scale limits: a single-instance primary with synchronous replication to a regional standby is sized for application workloads, not an unbounded purchase-history stream with concurrent customer queries. Strong consistency does hold here, so consistency is not the disqualifier; schema rigidity and instance-level scale ceilings are.
Option D, Firestore in Datastore mode with a global query, fails the first requirement in the way that matters. Datastore mode global (non-ancestor) queries are served from index replicas and are eventually consistent: a newly written purchase may not appear in a global query for a short window. Datastore mode does handle heterogeneous entities and sorted queries, so two of the three bullets pass — but "immediately after submission" does not. Native mode was introduced precisely to offer strongly consistent queries and real-time listeners.
The mechanism this question leans on without stating it is Firestore's consistency model split: Native mode gives strongly consistent single-document reads, collection queries, and listen streams, while Datastore mode keeps eventual consistency for global queries to keep them scalable across entity groups. Worked on this scenario, that single distinction is what separates option A from option D even though both are Firestore, both store varied document shapes, and both sort on indexed fields.
A further tie-breaker against C: Firestore's automatic indexing means adding a new sortable field (say, purchaseDate) requires no DDL or migration step, whereas a Cloud SQL schema change would need an ALTER TABLE and careful backfill on a live purchase table.
Exam Strategy
When an option requires reads "immediately after" a write, immediately test each candidate against the consistency model: Datastore mode global queries are eventually consistent, Native mode reads are strongly consistent. Then check the remaining bullets one at a time — schema flexibility rules out fixed-column Cloud SQL, and field-level filtering rules out Cloud Storage object reads. Two bullets often eliminate all but one Firestore mode; consistency is usually the tiebreaker.
Related Analysis
Practice All PCD Questions
Access 84 questions with complete answers and detailed explanations.
View Full PCD Practice Test →