April 2018
Intermediate to advanced
508 pages
15h 22m
English
A useful initial step to breaking a table into partitions is to figure out the range of data it contains, relative to the candidate field, and how large it is:
SELECT min(orderdate),max(orderdate) FROM orders;
min | max
------------+------------
2004-01-01 | 2004-12-31
SELECT relname,relpages FROM pg_class WHERE relname LIKE 'orders%' ORDER BY relname;
relname | relpages
--------------------+----------
orders | 100
orders_orderid_seq | 1
orders_pkey | 29
This is obviously too small to be worth partitioning but, for a demonstration sample, it's large enough to demonstrate how splitting the table would look. Since there's a year of data here, breaking that into month-sized pieces would be appropriate.
Read now
Unlock full access