Skip to content

STD-COD-004: Performance & Query Hygiene

1. Context

To prevent "Bill Shock" and "Spinner Hell". Performance is a feature.

2. The Standard (The Floor)

  • [MUST] The Rule of 100: No client-side query should fetch > 100 documents without Pagination.
  • [MUST] No N+1 Queries: Do not fetch related data in a loop. Use Promise.all or denormalization.
  • [MUST] Denormalization: For High-Read/Low-Write data (e.g., User Profiles on Posts), duplicate the data. Do NOT join at runtime.
  • [MUST] Indexing: All complex queries (where + orderBy) MUST have a composite index defined in firestore.indexes.json.

3. Best Practices (The Path)

  • [SHOULD] Server Caching: Use unstable_cache (Next.js) for static / semi-static data (e.g., Capability Matrix).
  • [SHOULD] Optimistic UI: Update the UI immediately on mutation; rollback on error.

5. Version History

Version Date Author Change
1.0 2026-01-25 AI Established Performance Standards

Version History

Version Date Author Change
0.1.0 2026-01-26 Antigravity Initial Audit & Metadata Injection