Chapter 06 · Indexes: Automatic/Composite/Collection-Group/Vector, Exemptions, and Index Cost

Enterprise Native Indexing Differences and Why Optional Indexing Changes Query-Performance Reasoning

Compare Firestore Enterprise Native optional indexing with Standard required indexing, table scans, Query Explain evidence, emulator edition support, and unit-based cost reasoning.

Intermediate130–155 minutesEnterprise optional indexing + ExplainFirebase JS 12.19.0 · CLI 15.30.0Last reviewed: September 2026

Learning outcomes

Suppose AtlasMart migrates the same catalog schema from Standard Native to Enterprise Native. The application issues category == camera ordered by price. In Standard, the query needs an index. In Enterprise, the query can run with no index at all. That sounds simpler—but a full collection scan can become slower and more expensive as the dataset grows. Success is therefore no longer sufficient evidence.

01

Contrast Standard required/automatic indexing with Enterprise optional/manual indexing without mixing their billing models.

02

Explain what a table scan means and why an unindexed Enterprise query can be correct yet non-performant or costly.

03

Use Enterprise emulator mode to prove index-optional query semantics while preserving the boundary that emulator runs do not prove production planner/cost.

04

Read managed Query Explain evidence such as TableScan, index IDs, documents scanned, and index entries scanned before adding an index.

05

Recognize specialized exceptions—especially vector search—where a compatible manual index is still required.

Execution and safety note

Use the Emulator Suite, a Firebase demo project, or an isolated test project for destructive, security-sensitive, billing-sensitive, migration, backup/restore, or write-heavy exercises unless the lesson explicitly marks managed verification as required. Treat shown output as expected evidence unless it is explicitly identified as captured output, and re-check current Firebase/Google Cloud edition, mode, quota, pricing, and security documentation before production execution.

Chapter 06 reproducibility baseline · reviewed 15 September 2026

AtlasMart continues the same environment used in Chapters 01–05: project ID demo-atlasmart-firestore, Standard edition / Native mode / (default) database for the main labs, Firestore emulator 127.0.0.1:8080, Authentication emulator 127.0.0.1:9099, Emulator UI 127.0.0.1:4000, Firebase CLI 15.30.0, Firebase JavaScript SDK 12.19.0, Firebase Admin Node SDK 14.4.0 (with @google-cloud/firestore 9.1.0), @firebase/rules-unit-testing 5.0.2, and Node.js 22+. The Enterprise-only exercise in Lesson 4 uses an isolated emulator configuration rather than mutating the Standard lab.

Evidence boundary for this generated lesson

The authoring environment did not execute Firebase emulators or a billed Firestore project. Local commands below are deterministic exercises to run on your machine; any shown output is labeled as an expected invariant, not captured benchmark evidence. The Firestore emulator does not reproduce production composite-index enforcement, managed index build/backfill state, billing, or production Query Explain metrics. Those observations are separated into optional managed-project checks.

1. Edition changes the default query/index contract

Question Standard Native Core Enterprise Native Core/Pipeline
Are indexes required for ordinary queries? Yes; queries are index-backed. No; unindexed queries can execute by scanning.
Are single-field indexes created automatically? Yes, subject to exemptions. No automatic indexes by default.
What happens when a useful index is absent? Unsupported query can fail and ask for an index. Query can succeed with a table/primary scan; performance/cost may degrade.
How do you decide to add an index? Correctness requirement plus scan/cost optimization. Query Explain/Insights + latency/cost/selectivity evidence.
Billing mental model Document operations plus applicable index-entry reads/storage. Read/write units based on byte tranches; index writes can add write-unit work.

Firestore release notes mark Enterprise edition Native mode and Pipeline operations GA as of 20 April 2026. That product-level status does not make every Enterprise capability GA; text/geospatial and some Pipeline DML capabilities have separate launch stages. Always read the current feature page before freezing a lab.

2. Optional indexes do not mean optional performance engineering

Enterprise can use an index when it reduces documents fetched, avoids sorting work, or covers fields needed by a query. Without a useful index, the engine can scan the primary collection. For a six-document emulator fixture that is fine. For millions of documents, the same logical query can consume dramatically more read units and latency.

The key design change is evidence timing. In Standard, missing index can be a hard correctness blocker. In Enterprise, the query can ship and silently become expensive as data grows unless you monitor Query Explain/Insights and SLOs. Index governance therefore needs performance regression tests, not just “query returned 200.”

3. Run Enterprise semantics in an isolated emulator configuration

Current Emulator Suite supports selecting standard or enterprise edition in firebase.json. Keep this exercise in a separate directory and ports so it cannot silently replace the Standard baseline used by Chapters 01–05.

enterprise-lab/firebase.json · isolated emulator
{  "firestore": {    "rules": "firestore.rules",    "indexes": "firestore.enterprise.indexes.json",    "edition": "enterprise"  },  "emulators": {    "firestore": { "port": 8180, "edition": "enterprise" },    "ui": { "enabled": true, "port": 4100 }  }}
enterprise-lab/firestore.enterprise.indexes.json · optional manual index
{  "indexes": [    {      "collectionGroup": "catalogItems",      "queryScope": "COLLECTION",      "density": "SPARSE_ANY",      "fields": [        { "fieldPath": "category", "order": "ASCENDING" },        { "fieldPath": "price", "order": "ASCENDING" }      ]    }  ],  "fieldOverrides": []}
enterprise-lab · start and run same query
mkdir enterprise-lab && cd enterprise-lab# place firebase.json, rules and optional index file herenpx firebase-tools@15.30.0 emulators:start --project demo-atlasmart-firestore --only firestore# in another terminal, seed the same six catalogItems against 127.0.0.1:8180# run category == camera + orderBy(price) first with no manual index, then with the config present
What the Enterprise emulator proves.

It can prove that your client/query code behaves against an Enterprise-edition emulator and that the result set is correct. It does not prove the managed query chose a TableScan, how many bytes/read units production consumed, or that a manual index improved p95/p99 latency.

4. Use Query Explain to distinguish scan from index use

Managed Enterprise Query Explain exposes an execution tree. A leaf TableScan means the query is reading primary storage without an index. When an index is used, the leaf identifies the index and indexed fields. Analyze/stats mode can report latency, documents scanned, index entries scanned, bytes/read units, and related runtime metrics depending on interface. Capture those numbers from your own bounded dataset; do not copy documentation samples into a capacity plan.

managed Enterprise · evidence procedure (pseudocode)
1. Seed N synthetic AtlasMart catalog documents; record N and average document bytes.2. Explain the target query with no manual index; save the plan and scan/byte metrics.3. Create the candidate index; wait until its managed state is READY.4. Explain the identical query again; save the new plan and metrics.5. Compare resultsReturned, documents/index entries scanned, bytes/read units and execution duration.6. Repeat enough times for a distribution if latency matters; do not call one request p95/p99.

For critical Enterprise workloads, the optimizer can also support explicit index control in current server APIs, but force-index behavior is an advanced operational tool. Diagnose with Query Explain first; a forced table scan on a large collection is specifically dangerous.

5. Enterprise index definitions have additional semantics

Enterprise manual indexes can use density and options not present in Standard's automatic defaults. A dense/non-sparse index can include documents even when indexed fields are missing (with missing values treated according to Enterprise index semantics), while sparse forms limit entries to documents with relevant field presence. MongoDB compatibility adds its own API scope and multikey concepts. Do not copy a Standard firestore.indexes.json file wholesale and assume identical behavior.

Core vs Pipeline.

Enterprise Native supports both interfaces. Core retains familiar where()/orderBy() and mobile/web realtime/offline integration. Pipeline supports more advanced server-side query composition. Their client availability, Security Rules constraints, offline/realtime behavior, and feature launch stages differ. This lesson uses Core-shaped catalog queries only so the indexing comparison is controlled.

6. Specialized boundary: vector search still needs a vector index

“Indexes are optional in Enterprise” must not be generalized to every specialized query. Firestore nearest-neighbor vector search requires a corresponding vector index. Current vector configuration uses a flat index and supports embedding dimensions up to 2048. AtlasMart will execute vector retrieval in Chapter 17; until then, the vector definition remains an explicitly owned future dependency, not a default index.

7. Wrong approach and repair

Wrong: “Enterprise lets my query run without an index, so indexes are unnecessary.”

This confuses correctness with efficiency. A scan can be correct on six rows and unacceptable at production cardinality. The repair is to define query/SLO/cost ownership, collect managed Explain/Insights evidence at realistic scale, add only indexes that materially reduce work, and retest after schema/cardinality changes.

The opposite wrong approach is to migrate every Standard automatic field index into Enterprise. That can recreate write/storage overhead Enterprise was designed to let you avoid. Start from query evidence, not from a fear of scans or a desire to mirror Standard.

Hands-on lab and verification checklist

  1. Create the isolated Enterprise emulator directory on ports 8180/4100.
  2. Run the same six-product query with no manual index; assert exact result IDs and stable order.
  3. Add the candidate Enterprise index configuration and rerun the semantic test. The result set must not change.
  4. Write a deterministic “scan budget” simulation that treats the six-document no-index case as six candidates and the indexed case as a reduced conceptual candidate set; label it simulation, not backend evidence.
  5. Optional managed Enterprise test: capture Query Explain before/after and record database edition, mode, location, document count/size, index readiness, and actual unit/latency metrics.
  6. Do not enable Enterprise or billing in a real project merely to finish the mandatory lesson; the emulator path is sufficient for learning semantics.

Production judgment

Enterprise indexing shifts the failure mode from “query fails without an index” toward “query can succeed inefficiently.” That increases the value of observability. Build SLO and cost alerts around real query distributions; never infer managed scan cost from emulator wall-clock time. Revisit indexes as cardinality/selectivity change.

Knowledge check

  1. What is the biggest indexing behavior difference between Standard and Enterprise Native?
  2. Why can an Enterprise query be correct but still be a production bug?
  3. What does a TableScan leaf in managed Query Explain mean?
  4. Why should Standard index configs not be copied wholesale into Enterprise?
  5. Does optional indexing make vector indexes optional for nearest-neighbor search?
Review the answers

1. Standard requires indexes and auto-creates single-field indexes; Enterprise creates no indexes by default and ordinary queries can scan without them.

2. It can return the right documents through a large table scan, causing poor latency and high read-unit cost as data grows.

3. The query is scanning primary collection storage rather than using an index for that access path.

4. Edition semantics, density/options, billing, and the absence of automatic indexing change which structures are justified.

5. No. Firestore vector search requires a compatible vector index.

Summary and next step

Enterprise turns indexing into an explicit performance/cost choice instead of a universal query prerequisite. Lesson 5 closes the chapter by auditing the combined manifest, removing the deliberately redundant structure, and defining before/after evidence plus rollback.

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.