Pcornel
Databases · Performance & Capacity

Table Partitioning

Cheat sheet · https://pcornel.dk/topic.php?topic=6200

Back to the Topic

Answer

Table partitioning splits a large table into partitions by a key (often date) so queries can prune partitions and old data can be dropped quickly.

Remember

Queries must filter on the partition key to prune. Too many partitions add planning overhead. Automate creating future partitions.

First checks

  • \d+ <table> — first check for this topic
  • psql -c "SELECT now(), version();" — PostgreSQL reachable and version
  • mysql -e "SELECT NOW(), VERSION();" — MariaDB/MySQL reachable and version
  • sqlcmd -S <server> -Q "SELECT @@VERSION" — SQL Server reachable and version

Verify in this order

row → partition by key → queries prune → old partitions dropped

Where it usually breaks

Queries without the partition key scan every partition.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6200

Confirmation

Confirm action

Continue?