Re: [HACKERS] Hash Functions - Mailing list pgsql-hackers

From Mark Dilger
Subject Re: [HACKERS] Hash Functions
Date
Msg-id 064B4781-E67C-467F-B0E3-C35FE9EDF75D@gmail.com
Whole thread Raw
In response to Re: [HACKERS] Hash Functions  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-hackers
> On May 15, 2017, at 7:48 AM, Jeff Davis <pgsql@j-davis.com> wrote:
>
> On Sun, May 14, 2017 at 6:22 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> You'd have to prohibit a heck of a lot more than that in order for
>> this to work 100% reliably.  You'd have to prohibit CHECK constraints,
>> triggers, rules, RLS policies, and UNIQUE indexes, at the least.  You
>> might be able to convince me that some of those things are useless
>> when applied to partitions, but wanting a CHECK constraint that
>> applies to only one partition seems pretty reasonable (e.g. CHECK that
>> records for older years are all in the 'inactive' state, or whatever).
>> I think getting this to work 100% reliably in all cases would require
>> an impractically large hammer.
>
> The more I think about it the more I think hash partitions are
> "semi-logical". A check constraint on a single partition of a
> range-partitioned table makes sense, but it doesn't make sense on a
> single partition of a hash-partitioned table.

That depends on whether the user gets to specify the hash function, perhaps
indirectly by specifying a user defined opfamily.  I can imagine clever hash
functions that preserve certain properties of the incoming data, and check
constraints in development versions of the database that help verify the hash
is not violating those properties.

That's not to say such hash functions must be allowed in the hash partitioning
implementation; just that it does make sense if you squint and look a bit sideways
at it.

Mark Dilger


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] NOT NULL constraints on range partition key columns
Next
From: David Fetter
Date:
Subject: Re: [HACKERS] Hash Functions