# Performance Optimization — NestJS

Source: https://www.geekswithgeeks.com/en/nestjs/nestjs-performance

> Optimize queries, use caching, and profile bottlenecks.

## Query optimization

Use `select` to fetch only needed columns; use `indices` in the DB; batch queries where possible.

## N+1 problem

Avoid loading related entities in a loop—use `leftJoinAndSelect()` or batch loaders to fetch all at once.
