What is 'Database Partitioning' and why is it used?

Instruction: Define database partitioning and discuss its benefits.

Context: This question explores the candidate's knowledge of database architecture optimizations, specifically partitioning for performance and management.

Updated

Official answer

Table partitioning divides a logical table into physical pieces according to a key, such as monthly date ranges, lists or hashes. In PostgreSQL declarative partitioning, queries can address the parent while eligible rows reside in partitions.

It can help lifecycle management, such as removing old periods, and queries that prune irrelevant partitions. A query over every period may gain little, and too many partitions can increase planning and maintenance work. Choose bounds from actual filters and retention needs; define handling for rows outside current ranges.

Partitioning is not automatically sharding across servers and is not replication. Splitting data does not make redundant copies or guarantee availability if storage fails. Backups and recovery remain separate responsibilities.

Check engine-specific restrictions on unique keys, foreign keys, indexes and attach/detach operations. A global uniqueness rule may need the partition key included or a different design. Measure representative queries and plan operational locks before changing an existing large table.

Related Questions