For those use case where it's necessary to have consistent hash function output (for same input id), we can create a user defined hash function to replace the system hash function. Or we can use a 3rd party extension to create a new function.
https://github.com/petere/pgvihash
- Download the extension file from above link.
- put the file at the master, unzip
- as root, cd to this directory, make sure GCC package already installed.
- as root, run "export PATH=$PATH:$GPHOME/bin/" , next "make"
- make sure below file exist at master node, if not, copy them from unzip directory to below location.
$GPHOME/share/postgresql/extension/vihash.control
$GPHOME/lib/postgresql/vihash.so
6. scp both file to each segment host.
7. For GPDB v6, psql, then : create extension vihash. For GDPB v5, psql, then run below :
CREATE OR REPLACE FUNCTION vihashtext(text) RETURNS int
AS '$libdir/vihash'
STRICT IMMUTABLE
LANGUAGE C;
8. verify the function : psql , select vihashtext('abc');