# Anti-Patterns Cross-cutting performance mistakes spanning all categories. identify before profiling. ## Data Fetching - **N+1 queries** → fetch parent, then query children per parent. batch with JOIN or eager loading. - **unbounded collection loading** → load all rows into memory. paginate or stream. - **extraneous fetching** → load columns/relations never used. select only needed fields. ## Connection & I/O - **no connection pooling** → establish/teardown per operation. pool connections. - **chatty I/O** → many small requests over network or disk. batch into single round-trip. - **sync blocking in async code** → call blocking I/O from async path. use async APIs or offload to worker. - **improper instantiation** → create/destroy shared objects per use. reuse singletons or pooled instances. ## Resilience - **retry storm** → unbounded retries without backoff or circuit breaker. cap retries, add backoff, use circuit breaker. - **no caching** → fetch same data repeatedly from backend. cache frequently-read data. ## Memory - **unbounded growth** → collections/queues with no eviction or limit. bound caches, add TTL. - **memory leaks** → listeners, callbacks, references retained indefinitely. clean up handlers on teardown. - **string concatenation in hot path** → O(n²) repeated concatenation. use builder/buffer. ## Design - **premature optimization** → tune before measuring. profile first, optimize measured bottlenecks. - **performance decorations** → optimizations that look fast but have no impact. verify with benchmarks. - **nosy neighbor** → single tenant/workload consuming disproportionate resources. isolate or quota. - **busy database** → offload all processing to the data store. move logic to application where appropriate. - **monolithic persistence** → one store for data with very different usage patterns. split by access pattern. ## Detection - profile before optimizing - benchmark before and after changes - watch for patterns above during code review - load test with realistic data volumes before production