pgmp
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgmp | 1.0.5 | TYPE | LGPL-3.0 | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3700 | pgmp | No | Yes | No | Yes | No | Yes | - |
| Related | numeral unit pguecc pgcrypto prefix semver pgpdf pglite_fusion |
|---|
missing pg14 on el pgdg repo
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.0.5 | 1817161514 | pgmp | - |
| RPM | PGDG | 1.0.5 | 1817161514 | pgmp_$v | - |
| DEB | PGDG | 1.0.5 | 1817161514 | postgresql-$v-pgmp | - |
Install
You can install pgmp directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pgmp; # Install for current active PG version
pig ext install -y pgmp -v 18 # PG 18
pig ext install -y pgmp -v 17 # PG 17
pig ext install -y pgmp -v 16 # PG 16
pig ext install -y pgmp -v 15 # PG 15
pig ext install -y pgmp -v 14 # PG 14
dnf install -y pgmp_18 # PG 18
dnf install -y pgmp_17 # PG 17
dnf install -y pgmp_16 # PG 16
dnf install -y pgmp_15 # PG 15
dnf install -y pgmp_14 # PG 14
apt install -y postgresql-18-pgmp # PG 18
apt install -y postgresql-17-pgmp # PG 17
apt install -y postgresql-16-pgmp # PG 16
apt install -y postgresql-15-pgmp # PG 15
apt install -y postgresql-14-pgmp # PG 14
Create Extension:
CREATE EXTENSION pgmp;
Usage
The pgmp extension integrates the GNU Multiple Precision (GMP) library into PostgreSQL, providing arbitrary-precision integer and rational number types.
CREATE EXTENSION pgmp;
Data Types
mpz: Arbitrary-size integers, limited only by PostgreSQL’s 1GB varlena maximummpq: Arbitrary-precision rational numbers for exact fractional arithmetic
Basic Usage
-- Arbitrary precision integers
SELECT '123456789012345678901234567890'::mpz * 2;
-- Exact rational arithmetic (no rounding)
SELECT '1'::mpq / '3'::mpq; -- 1/3
-- Mixed arithmetic with native PostgreSQL types
SELECT 42::mpz + '100'::mpz;
Operators
Standard arithmetic operators (+, -, *, /, %) and comparison operators (=, <>, <, >, <=, >=) are supported for both mpz and mpq.
Functions
The extension exposes all GMP library functions for these types, including:
- Prime number functions
- Random number generation
- Factorization
- GCD, LCM, and other number theory functions
Index Support
Both mpz and mpq support btree and hash indexes for efficient queries and sorting.
Full documentation: https://www.varrazzo.com/pgmp/
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.