SQL queries request or manipulate data in relational databases. In scalable applications, query behavior matters because inefficient queries slow down as data and request volume increase. section 6.4.1
Keep SQL query performance under control by:
- Logging query performance during each request, then investigating slow queries and requests that generate many queries. section 6.4.1
- Using EXPLAIN in MySQL or PostgreSQL to analyze specific queries. section 6.4.1
- Adding indexes for commonly searched columns and reducing unnecessary JOIN operations. section 6.4.1
- Avoiding N+1 queries by serving object lists without issuing a separate query for every object. section 6.4.1
Listing related objects
A request that renders a list should ideally use a constant number of database queries rather than one query for the list plus a separate query for each displayed object. section 6.4.1
























