SQL and databases

6 questions

How to optimize queries?

EXPLAIN.
Indexes.
Avoid SELECT *.
LIMIT.
No functions on indexes.

PostgreSQL vs MySQL?

PG: complex queries.
MySQL: simple CRUD.
PG is stricter.
MySQL reads faster.
Both production-ready.

SQL and databases: how to design schema and normalize tables?

Regarding «SQL and databases», start with reproducibility: minimal example, version, steps. This is half of debugging.

SQL and Databases: How to choose indexes and read EXPLAIN plans?

Practice for "SQL and Databases": write a test/check that breaks, then fix the code. This way you don't "treat symptoms".

SQL and Databases: How to perform migrations and version the schema?

Answer on "SQL and Databases": read the documentation and errors thoroughly. An error message almost always indicates what is wrong.

SQL and Databases: How to set up backups and recovery?

For "SQL and Databases" it is useful: logging, profiling, and working with metrics. Optimization without measurements is guesswork.