MySQL interview question · Most asked
MySQL or PostgreSQL: how would you choose for a new project?
Summary
Both are mature and handle most OLTP workloads well. PostgreSQL offers richer SQL and types (JSONB with GIN indexes, arrays, partial and expression indexes, extensions such as PostGIS and pgvector, transactional DDL). MySQL is simple to operate, very well understood at web scale, and has strong replication tooling and managed offerings. Team experience and ecosystem often decide.
Longer Answer
Lean to PostgreSQL for complex queries and analytics, rich data types, geospatial, strict standards behaviour, or many extensions. Lean to MySQL when the team and tooling are MySQL-centric, for very read-heavy web workloads with familiar replication, or for compatibility with existing systems (Vitess for sharding).
Operational differences matter: PostgreSQL needs VACUUM tuning and uses a process per connection (pooling with PgBouncer is common); MySQL's clustered primary key makes PK choice more critical.
Key Points
- Both are excellent for OLTP.
- PostgreSQL: richer SQL, types, extensions.
- MySQL: operational simplicity, ecosystem.
- Team experience often decides.
Explanation
What interviewers look for
A balanced comparison with concrete differences, not tribal preference.
More most-asked MySQL questions
- What is a clustered index in InnoDB, and why does primary key choice matter so much?
- Why is OFFSET pagination slow on large tables, and what is keyset pagination?
- How do you read EXPLAIN output in MySQL?
- Why might MySQL not use an index you created?
- What are the transaction isolation levels, and which does InnoDB use by default?
- How does a composite index work, and what is the leftmost-prefix rule?
- What causes deadlocks in MySQL, and how do you handle them?
- What are gap locks and next-key locks, and why do they surprise developers?