hashtypes

sha1, md5 and other data types for PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
hashtypes0.1.5TYPEPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
3750hashtypesNoYesNoYesNoNo-
Relatedprefix semver unit pgpdf pglite_fusion md5hash asn1oid roaringbitmap

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.1.51817161514hashtypes-
RPMPIGSTY0.1.51817161514hashtypes_$v-
DEBPIGSTY0.1.51817161514postgresql-$v-hashtypes-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
d13.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
u22.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
u22.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
u24.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
u24.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5

Build

You can build the RPM / DEB packages for hashtypes using pig build:

pig build pkg hashtypes         # build RPM / DEB packages

Install

You can install hashtypes directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install hashtypes;          # Install for current active PG version
pig ext install -y hashtypes -v 18  # PG 18
pig ext install -y hashtypes -v 17  # PG 17
pig ext install -y hashtypes -v 16  # PG 16
pig ext install -y hashtypes -v 15  # PG 15
pig ext install -y hashtypes -v 14  # PG 14
dnf install -y hashtypes_18       # PG 18
dnf install -y hashtypes_17       # PG 17
dnf install -y hashtypes_16       # PG 16
dnf install -y hashtypes_15       # PG 15
dnf install -y hashtypes_14       # PG 14
apt install -y postgresql-18-hashtypes   # PG 18
apt install -y postgresql-17-hashtypes   # PG 17
apt install -y postgresql-16-hashtypes   # PG 16
apt install -y postgresql-15-hashtypes   # PG 15
apt install -y postgresql-14-hashtypes   # PG 14

Create Extension:

CREATE EXTENSION hashtypes;

Usage

hashtypes: hash and checksum data types (SHA, CRC32)

The hashtypes extension provides native data types for storing hash values and checksums in their binary representation, saving storage compared to text.

CREATE EXTENSION hashtypes;

Data Types

TypeStorageDescription
sha120 bytesSHA-1 hash (160-bit)
sha22428 bytesSHA-224 hash (224-bit)
sha25632 bytesSHA-256 hash (256-bit)
sha38448 bytesSHA-384 hash (384-bit)
sha51264 bytesSHA-512 hash (512-bit)
crc324 bytesCRC-32 checksum

Usage

CREATE TABLE objects (
    hash sha256 PRIMARY KEY,
    data bytea
);

INSERT INTO objects VALUES (
    'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
    '\x'
);

SELECT * FROM objects WHERE hash = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';

Operators

All types support comparison operators: =, <>, <, >, <=, >=.

Index Support

Btree and hash index operator classes are provided for all types.

Casts

All types support bidirectional casts to/from text and bytea.


Last Modified 2026-03-12: add pg extension catalog (95749bf)