Re: Define hash partition for certain column values

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Голубева Яна <ishsha(at)yandex(dot)ru>
Cc: Michael Lewis <mlewis(at)entrata(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Define hash partition for certain column values
Date: 2021-01-12 16:37:17
Message-ID: BD71D753-7E4D-4A80-9563-55AB07C36C0C@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> On 12 Jan 2021, at 16:51, Голубева Яна <ishsha(at)yandex(dot)ru> wrote:
>
> Values for the key partitioning column are generated randomly and I can't predict their distribution between ranges.
> If I just create some ranges I won't have any guarantee that partitions will have similar amount of data. It is possible that I will have 2 or 3 extremely big partitions and a bit of data in others.

A hash of a random number is also random, so when using hashes for partitioning you will get the same problem.

If you want to distribute values equally over a fixed number of partitions, I suggest you partition on a modulo of a monotonously increasing number (a sequence for example), instead of relying on a random number.

> 12.01.2021, 17:55, "Michael Lewis" <mlewis(at)entrata(dot)com>:
> On Tue, Jan 12, 2021 at 1:21 AM Голубева Яна <ishsha(at)yandex(dot)ru> wrote:
> List or range partitioning isn't suitable for my case.
> I am using a column of numeric(20) type as a base for partitioning. The values of the column are generated randomly.
> So there will be too many partitions if I use list partitioning as is.
>
> Sorry, but why is range not suited for this? It would seem fairly trivial to create 50 or 1000 partitions to break up the range of values allowed by your field definition.

Alban Hertroys
--
There is always an exception to always.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2021-01-12 16:41:01 Re: Define hash partition for certain column values
Previous Message Rob Sargent 2021-01-12 15:55:06 Re: Define hash partition for certain column values