pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedHash partitioning, what function is used to compute the hash?
5+ messages / 4 participants
[nested] [flat]
* Hash partitioning, what function is used to compute the hash?
@ 2020-05-11 04:33 Dennis Ryan <dennisr1963@outlook.com>
2020-05-11 13:08 ` Re: Hash partitioning, what function is used to compute the hash? Michael Lewis <mlewis@entrata.com>
2020-05-11 16:28 ` Re: Hash partitioning, what function is used to compute the hash? Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 2 replies; 5+ messages in thread
From: Dennis Ryan @ 2020-05-11 04:33 UTC (permalink / raw)
To: pgsql-general
Regarding hash partitioning, what is the function/algorithm that is used to compute the hash for the partition key? I need to write a query like
“SELECT unknown_partition_hash_function(id) AS hash_value, COUNT(id) AS number_of_records
FROM existing_table
GROUP BY 1”
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986; for Windows 10
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Hash partitioning, what function is used to compute the hash?
2020-05-11 04:33 Hash partitioning, what function is used to compute the hash? Dennis Ryan <dennisr1963@outlook.com>
@ 2020-05-11 13:08 ` Michael Lewis <mlewis@entrata.com>
2020-05-11 21:13 ` Re: Hash partitioning, what function is used to compute the hash? Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 1 reply; 5+ messages in thread
From: Michael Lewis @ 2020-05-11 13:08 UTC (permalink / raw)
To: Dennis Ryan <dennisr1963@outlook.com>; +Cc: pgsql-general
The documentation shows it is just a modulus operation. If you partition on
object_key % 3 then you will create three partitions for remainder values
0-2 for instance.
Afaik, hash partition doesn't have real world expected use cases just yet.
List or range is probably what you want to use.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Hash partitioning, what function is used to compute the hash?
2020-05-11 04:33 Hash partitioning, what function is used to compute the hash? Dennis Ryan <dennisr1963@outlook.com>
2020-05-11 13:08 ` Re: Hash partitioning, what function is used to compute the hash? Michael Lewis <mlewis@entrata.com>
@ 2020-05-11 21:13 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2020-05-12 15:51 ` Re: Hash partitioning, what function is used to compute the hash? Michael Lewis <mlewis@entrata.com>
0 siblings, 1 reply; 5+ messages in thread
From: Alvaro Herrera @ 2020-05-11 21:13 UTC (permalink / raw)
To: Michael Lewis <mlewis@entrata.com>; +Cc: Dennis Ryan <dennisr1963@outlook.com>; pgsql-general
On 2020-May-11, Michael Lewis wrote:
> Afaik, hash partition doesn't have real world expected use cases just yet.
I don't think I agree with this assertion.
While I understand that there might be things still to do in this area
(as everywhere else), it should certainly have its uses already. If you
have a wish-list for hash partitioning to become usable for you, would
you please list the features you wish it'd have?
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Hash partitioning, what function is used to compute the hash?
2020-05-11 04:33 Hash partitioning, what function is used to compute the hash? Dennis Ryan <dennisr1963@outlook.com>
2020-05-11 13:08 ` Re: Hash partitioning, what function is used to compute the hash? Michael Lewis <mlewis@entrata.com>
2020-05-11 21:13 ` Re: Hash partitioning, what function is used to compute the hash? Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2020-05-12 15:51 ` Michael Lewis <mlewis@entrata.com>
0 siblings, 0 replies; 5+ messages in thread
From: Michael Lewis @ 2020-05-12 15:51 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Dennis Ryan <dennisr1963@outlook.com>; pgsql-general
On Mon, May 11, 2020 at 3:13 PM Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
> On 2020-May-11, Michael Lewis wrote:
>
> > Afaik, hash partition doesn't have real world expected use cases just
> yet.
>
> I don't think I agree with this assertion.
>
I didn't mean to be critical at all, or even make a statement of fact. Just
sharing my impression. I typically view partitioning from the perspective
of multi-tenancy and with the restrictions on primary keys & partition
keys, I can't typically use partitioning except for audit logging tables
and then range partitions make the most sense there because of doing
backups and dropping the oldest data. Perhaps it is just that hash has
never been the right tool for my use cases. I'd love to know some real life
examples of when hash partitioning was the best option.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Hash partitioning, what function is used to compute the hash?
2020-05-11 04:33 Hash partitioning, what function is used to compute the hash? Dennis Ryan <dennisr1963@outlook.com>
@ 2020-05-11 16:28 ` Laurenz Albe <laurenz.albe@cybertec.at>
1 sibling, 0 replies; 5+ messages in thread
From: Laurenz Albe @ 2020-05-11 16:28 UTC (permalink / raw)
To: Dennis Ryan <dennisr1963@outlook.com>; pgsql-general
On Mon, 2020-05-11 at 04:33 +0000, Dennis Ryan wrote:
> Regarding hash partitioning, what is the function/algorithm that is used to compute the hash for the partition key? I need to write a query like
>
> “SELECT unknown_partition_hash_function(id) AS hash_value, COUNT(id) AS number_of_records
> FROM existing_table
> GROUP BY 1”
To find the function that PostgreSQL uses to hash a data type,
try something like
SELECT amp.amproc,
amp.amproclefttype::regtype
FROM pg_amproc AS amp
JOIN pg_opfamily AS opf ON amp.amprocfamily = opf.oid
JOIN pg_am ON opf.opfmethod = pg_am.oid
WHERE pg_am.amname = 'hash'
AND amp.amprocnum = 1;
Yours,
Laurenz Albe
--
+43-670-6056265
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-05-12 15:51 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 04:33 Hash partitioning, what function is used to compute the hash? Dennis Ryan <dennisr1963@outlook.com>
2020-05-11 13:08 ` Michael Lewis <mlewis@entrata.com>
2020-05-11 21:13 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2020-05-12 15:51 ` Michael Lewis <mlewis@entrata.com>
2020-05-11 16:28 ` Laurenz Albe <laurenz.albe@cybertec.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox