Why You Need a Default Partition
Postgres and YugabyteDB allow you to define partitions of parent tables. Partitions are useful in at least two ways:
- You can take advantage of partition pruning. The database doesn’t need to look at partitions it knows won’t meet the parameters of the query.
- You can easily archive data by disconnecting and/or dropping partitions instead of managing expensive delete queries.
Here’s one gotcha I ran into recently. What happens if you insert a row into a partitioned table, but there’s no partition for it? The insert fails with an error – see below for a reproduction of this scenario.