3 ms·
EDIT: oops, link updated. Thanks justinclift! Performance, mainly. Partitioning mean your data can be spread across more physical areas (or FS partitions, or
by rorygibson 9y ago
EDIT: oops, link updated. Thanks justinclift!
Performance, mainly.
Partitioning mean your data can be spread across more physical areas (or FS partitions, or whatever) at lower level, giving the database (and you) more control of performance by optimising what gets stored where at a lower level.
Official pg doc here: https://www.postgresql.org/docs/10/static/ddl-partitioning.html https://www.postgresql.org/docs/10/static/ddl-partitioning.h... - the pertinent bits are as follows:
---
Partitioning can provide several benefits:
- Query performance can be improved dramatically in certain situations, particularly when most of the heavily accessed rows of the table are in a single partition or a small number of partitions. The partitioning substitutes for leading columns of indexes, reducing index size and making it more likely that the heavily-used parts of the indexes fit in memory.
- When queries or updates access a large percentage of a single partition, performance can be improved by taking advantage of sequential scan of that partition instead of using an index and random access reads scattered across the whole table.
- Bulk loads and deletes can be accomplished by adding or removing partitions, if that requirement is planned into the partitioning design. ALTER TABLE NO INHERIT and DROP TABLE are both far faster than a bulk operation. These commands also entirely avoid the VACUUM overhead caused by a bulk DELETE.
- Seldom-used data can be migrated to cheaper and slower storage media.
The benefits will normally be worthwhile only when a table would otherwise be very large. The exact point at which a table will benefit from partitioning depends on the application, although a rule of thumb is that the size of the table should exceed the physical memory of the database server.
- andy_ppp 9y agoOkay - so the partitioning gives better per machine performance by allowing you to parallelise certain things and spread out on disk. I thought this was similar to Cassandra's ring based partitioning that allows data to be distributed around many machines. Thanks for clarifying.
- Tostino 9y agoThat will eventually be coming in some form. In the OP link, there was a mention of foreign tables participating in partitioning: > While foreign tables can be partitions in v10, they are currently subject to an unfortunate limitation: tuple inserts that route to a foreign table will fail, since this feature has not been implemented yet. Etsuro Fujita (NTT) is working to address this limitation by revising code originally written by Amit Langote. So there is work on getting this to scale on multiple machines, rather than just single machine. We're just not there yet.
- justinclift 9y agoMight be better to use the v10 version of that doc, instead of the v9.1 one: https://www.postgresql.org/docs/10/static/ddl-partitioning.html https://www.postgresql.org/docs/10/static/ddl-partitioning.h... 9.1 is unsupported these days, etc. :)