Persistence.
WHAT TO SET UP
Database credentials in configuration, not code A connection approach suited to a persistent application
WHAT TO BE CAREFUL WITH
Opening a connection per request without pooling Holding a connection open indefinitely Connections not closed on error
WHAT TO USE
Your framework's database integration, or a connection pool.
WHAT TO ALWAYS DO
Parameterise queries.
WHAT TO CONSIDER
Whether an ORM suits the project.
WHAT AN ORM GIVES YOU
Working with objects rather than rows Portability between databases Migrations for schema changes
WHAT IT COSTS
A layer of abstraction, and queries that are sometimes inefficient.
WHAT TO WATCH FOR
Queries issued inside a loop, producing one query per item.
That is the commonest performance problem in database-backed applications.
WHAT TO DO ABOUT IT
Fetch what you need in one query.
WHAT TO MONITOR
Query count and duration.
WHAT TO PLAN
Schema changes, with a way to apply them repeatably.