Advanced Topic 36 of 51 Databases
Database Partitioning
Splitting tables into smaller physical pieces.
How it works
Partitioning splits a large table into smaller pieces, partitions, stored separately but queried as one table. Common methods are range partitioning, for example by date, list partitioning by a value such as region, and hash partitioning to spread rows evenly. The optimizer can skip irrelevant partitions, called partition pruning, and old partitions can be dropped or archived quickly. Horizontal partitioning splits rows, while vertical partitioning splits columns.
Step-by-step walkthrough
- A large table is split into partitions by rule, such as year.
- A query for 2024 touches only that partition, called pruning.
- Old partitions can be dropped or archived quickly.
- Maintenance such as vacuum works per partition.
- The table still looks like one table to applications.
Where it is used
Time-series and log tables, large event stores and tenant-based data benefit from partitioning, which makes maintenance and queries faster.
Common pitfall
Choosing a poor partition key creates uneven partitions or queries that touch all of them. Too many partitions add planning overhead. Unique constraints often must include the partition key. Queries that do not filter on the key scan every partition. Plan retention and automate partition creation.
Where it fits in the course
Database Partitioning is topic 36 of 51 in Databases, rated Advanced. It follows Recovery and Logging. The next topic is Replication.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Databases quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Databases quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Database Partitioning?
Where do people use Database Partitioning?
What is the most common mistake with Database Partitioning?
What should I learn before this topic?
How can I practice it?
Is Database Partitioning hard to learn?
How long does it take to learn Database Partitioning?
Which topics are related to Database Partitioning?
What should I study after Database Partitioning?
Related topics
- Recovery and Logging (Databases)
- Replication (Databases)
- Common Table Expressions (Databases)
- Sharding (Databases)