When to use PARTITION BY HASH?

From: Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org, pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: When to use PARTITION BY HASH?
Date: 2020-06-02 17:17:11
Message-ID: CACACo5StuUuFox+65KQHB8u+51kMUcEeQuV=XmsUv7d8VnaO7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

Hi!

I was reading up on declarative partitioning[1] and I'm not sure what could
be a possible application of Hash partitioning.

Is anyone actually using it? What are typical use cases? What benefits
does such a partitioning scheme provide?

On its face, it seems that it can only give you a number of tables which
are smaller than the un-partitioned one, but I fail to see how it would
provide any of the potential advantages listed in the documentation.

With a reasonable hash function, the distribution of rows across partitions
should be more or less equal, so I wouldn't expect any of the following to
hold true:
- "...most of the heavily accessed rows of the table are in a single
partition or a small number of partitions."
- "Bulk loads and deletes can be accomplished by adding or removing
partitions...",
etc.

That *might* turn out to be the case with a small number of distinct values
in the partitioning column(s), but then why rely on hash assignment instead
of using PARTITION BY LIST in the first place?

Regards,
--
Alex

[1] https://www.postgresql.org/docs/12/ddl-partitioning.html

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Pryzby 2020-06-02 17:33:54 Re: When to use PARTITION BY HASH?
Previous Message Michael Nolan 2020-06-02 15:32:10 Re: Oracle vs. PostgreSQL - a comment

Browse pgsql-performance by date

  From Date Subject
Next Message Justin Pryzby 2020-06-02 17:33:54 Re: When to use PARTITION BY HASH?
Previous Message Filip Rembiałkowski 2020-06-01 13:24:42 Re: Configuration