What is database partitioning in MySQL?

Why Interviewers Ask This

Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.

Answer

Partitioning divides a single large table into multiple smaller physical partitions while appearing as one logical table to queries. MySQL handles routing to the correct partition transparently. Unlike sharding (across multiple servers), partitioning happens within a single MySQL instance. Types: RANGE: rows assigned based on column value ranges — PARTITION BY RANGE (YEAR(created_at)) — common for date-based data; LIST: rows assigned based on specific discrete values — PARTITION BY LIST (region_id); HASH: rows distributed evenly across N partitions based on a hash of a column — PARTITION BY HASH(user_id) PARTITIONS 8; KEY: similar to HASH but uses MySQL's internal hash function. Benefits: (1) Partition pruning — queries with WHERE on the partition key only scan relevant partitions, not the whole table; (2) Faster DELETE of old data — drop entire partitions: ALTER TABLE logs DROP PARTITION p_2022;; (3) Parallelism. Limitations: partition expressions have restrictions; foreign keys not supported on partitioned tables; max 8192 partitions per table. Best for: time-series data with archival needs, very large tables with predictable query patterns.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last MySQL / SQL project, I used this when...' immediately makes your answer more credible and memorable.