AI created slow and expensive code. How I analyzed and fixed it.

TL;DR AI
2 min readKey summary
An AI-built browser game portal started exceeding Firebase free-tier limits and slowing down.
The developer used billing, query, and latency metrics to pinpoint the worst hotspots.
The main issues were inefficient Firestore access in a nightly cleanup job, a heavy profile endpoint, and an expensive random-seed generator.
They began replacing broad scans and repeated queries with more targeted Firestore reads to cut cost and latency.

