Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kyshV-0006vF-Jr for pgsql-general@arkaria.postgresql.org; Mon, 11 Jan 2021 08:37:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kysgy-0007to-9J for pgsql-general@arkaria.postgresql.org; Mon, 11 Jan 2021 08:36:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kysgx-0007th-Ut for pgsql-general@lists.postgresql.org; Mon, 11 Jan 2021 08:36:48 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kysgv-0006bj-GF for pgsql-general@lists.postgresql.org; Mon, 11 Jan 2021 08:36:47 +0000 Received: by mail-ot1-x333.google.com with SMTP id a109so16201334otc.1 for ; Mon, 11 Jan 2021 00:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=gE1CJ2YkjJHzzErtn10d2RCFlCWkPscmDYHzWjcG0dw=; b=UGnYCzJyiAp7d8R6ui1xr+xLgsBOneNVxoqMpRv8mv+I5B+bEuHY/LmIhALNs0TnGL EaxDi2ZPRgJJ6BJXJXIR9h7OBM7rJmcJvGoy0CvwNHTp5dZpcseUsgMDCcuWuqHvvMLh tPwcYu4dlOrjqBO7wdfWALS6AT4g+zXgfqUAbXNEoPrDzhE8aF410tgUK4u8r4qezMVz i38RgqsGOx0gnAx/j4N7AHt8YODM34ZKytl5EunSHK8gHF6vQ9ZfbA+RgmqlcwMVs0n0 6KHwLSQmxAbnQcGCrt8dJ9GmycVGVzUvwWWhq9GjwJ1x3xK9rAXmt1kfOOXpt09mDt66 xGzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=gE1CJ2YkjJHzzErtn10d2RCFlCWkPscmDYHzWjcG0dw=; b=GCossL0kV3+7tJEHjcUCQhJWlP3RQnGgIkQPKr+AisZd28S6MjiRLXxMC/uY1i7RYr JKo+6dvyqPk49WGBuK3TspDZgu/F8AOODhCHiWQNaN1Q2IBFOx4ly9mB5dKb53P0dY28 CgAcC0Q/CpEyNGSz8buXRxMTmWH/PKdnFXzhKG4gv7+1DNJAXOud/aI/xd/6qiNtXtEA PWM0l5z3zJ8FqTk90o5A1yERLIU7WkVWIWI4WSI1JmXTTgVdh43kIsirM6sikMGW4V5M XN/opzTz+s6bq4USjhKpVxQoYDf2UAHazQwzENxZIFomU8atIMAxXTQnKmjpWnHnmTr1 VTlg== X-Gm-Message-State: AOAM531YUDIUeUIOE1gPONCxt4KFClcfqLhJZZ3aO0YBnS1aI2Ktnupg nuxWP227BodSbu7+j5ivyOH2cyzctLWQrw== X-Google-Smtp-Source: ABdhPJwgJ+lFlZsCJf4OjUZ+sgGOo8JP1grur5izKZ/c/po7Y5QoSjkffn2BVe9NuX+WvrFJpvUHPQ== X-Received: by 2002:a9d:508:: with SMTP id 8mr10356485otw.338.1610354203352; Mon, 11 Jan 2021 00:36:43 -0800 (PST) Received: from [192.168.1.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id o135sm3179423ooo.38.2021.01.11.00.36.42 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Jan 2021 00:36:42 -0800 (PST) Subject: Re: Define hash partition for certain column values To: pgsql-general@lists.postgresql.org References: <2278581610342154@mail.yandex.ru> <820805.1610346968@sss.pgh.pa.us> From: Ron Message-ID: <156c6b19-1eca-25bc-abb3-de7a598a2647@gmail.com> Date: Mon, 11 Jan 2021 02:36:41 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <820805.1610346968@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------1F43C5503E58D3AF16F0DD69" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------1F43C5503E58D3AF16F0DD69 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 1/11/21 12:36 AM, Tom Lane wrote: > =?utf-8?B?0JPQvtC70YPQsdC10LLQsCDQr9C90LA=?= writes: >> Hello, I've found in source code that there is a function satisfies_hash_partition(oid, modulus, remainder, column_values[]) which allows to check if the certain column value will be placed in the certain partition. I' d like to know if there is an opportunity not to check the certain partition but to define which partition will be the certain column value placed in. > If you want to control what goes where, use list partitioning (or, > perhaps, range partitioning). Hash is only suitable if you do not > care which partition any particular row goes to. > > Personally, I think hash partitioning is mostly academic, precisely > because of that. If the partitioning doesn't line up with application > requirements, you give up too much of the benefit of using partitions. In non-MBCC systems, hash partitioning minimizes lock conflicts because the writes aren't all going into the same page.  OLTP systems can use this feature to distribute writes across pages; some also allow for "mixed pages", where records from multiple tables get written to the same page.  (This then means that one DIO is used to read a parent and all it's child records.  Naturally, range reports are *very* slow, but sometimes OLTP performance is paramount.) -- Angular momentum makes the world go 'round. --------------1F43C5503E58D3AF16F0DD69 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 1/11/21 12:36 AM, Tom Lane wrote:
=?utf-8?B?0JPQvtC70YPQsdC10LLQsCDQr9C90LA=?= <ishsha@yandex.ru> writes:
Hello,  I've found in source code that there is a function satisfies_hash_partition(oid, modulus, remainder, column_values[]) which allows to check if the certain column value will be placed in the certain partition. I' d like to know if there is an opportunity not to check the certain partition but to define which partition will be the certain column value placed in.
If you want to control what goes where, use list partitioning (or,
perhaps, range partitioning).  Hash is only suitable if you do not
care which partition any particular row goes to.

Personally, I think hash partitioning is mostly academic, precisely
because of that.  If the partitioning doesn't line up with application
requirements, you give up too much of the benefit of using partitions.

In non-MBCC systems, hash partitioning minimizes lock conflicts because the writes aren't all going into the same page.  OLTP systems can use this feature to distribute writes across pages; some also allow for "mixed pages", where records from multiple tables get written to the same page.  (This then means that one DIO is used to read a parent and all it's child records.  Naturally, range reports are very slow, but sometimes OLTP performance is paramount.)

--
Angular momentum makes the world go 'round.
--------------1F43C5503E58D3AF16F0DD69--