InterviewHubPRO
Section Overview
Q14

Question 14 of 60

Part 2: Relational Databases (RDBMS / PostgreSQL / MySQL) (6 - 25)

23%
Databases & System Design•Part 2: Relational Databases (RDBMS / PostgreSQL / MySQL) (6 - 25)

EXPLAIN vs EXPLAIN ANALYZE:

In Simple Words:

  • EXPLAIN: Shows the optimizer's estimated execution plan without running the query.
  • EXPLAIN ANALYZE: Actually executes the query, reporting real execution times, buffer hits, and scan types (Sequential Scan vs Index Scan).
sql
EXPLAIN (ANALYZE, BUFFERS)
SELECT u.name, count(o.id) 
FROM users u 
JOIN orders o ON u.id = o.user_id 
WHERE u.created_at >= '2025-01-01' 
GROUP BY u.name;