Re: When to use PARTITION BY HASH? - Mailing list pgsql-general

From Jeff Janes
Subject Re: When to use PARTITION BY HASH?
Date
Msg-id CAMkU=1w0JzvpjrNFmQJ94w1+JrF+XeY0_5f9Z9R4mZr6hOOpkg@mail.gmail.com
Whole thread Raw
In response to Re: When to use PARTITION BY HASH?  (Oleksandr Shulgin <oleksandr.shulgin@zalando.de>)
Responses Re: When to use PARTITION BY HASH?  (Oleksandr Shulgin <oleksandr.shulgin@zalando.de>)
List pgsql-general
On Wed, Jun 3, 2020 at 7:55 AM Oleksandr Shulgin <oleksandr.shulgin@zalando.de> wrote:

With hash partitioning you are not expected, in general, to end up with a small number of partitions being accessed more heavily than the rest.  So your indexes will also not fit into memory.

I have the feeling that using a hash function to distribute rows simply contradicts the basic assumption of when you would think of partitioning your table at all: that is to make sure the most active part of the table and indexes is small enough to be cached in memory.

While hash partitioning doesn't appeal to me, I think this may be overly pessimistic.  It would not be all that unusual for your customers to take turns being highly active and less active.  Especially if you do occasional bulk loads all with the same customer_id for any given load, for example.  So while you might not have a permanently hot partition, you could have partitions which are hot in turn.  Of course you could get the same benefit (and probably better) with list or range partitioning rather than hash, but then you have to maintain those lists or ranges when you add new customers.

Cheers,

Jeff

pgsql-general by date:

Previous
From: Matt Zagrabelny
Date:
Subject: Re: Can we get SQL Server-like cross database queries
Next
From: Susan Joseph
Date:
Subject: PostgreSQL 11 with SSL on Linux