PIGSTY

pgml

Run AL/ML workloads with SQL interface

Overview

Attributes

YesNoYesYesYesNoNopgml

Packages

EL
PIGSTY
pgml_$v2.10.0-
17
16
15
14
13
Debian
PIGSTY
postgresql-$v-pgml2.10.0-
17
16
15
14
13

Comments

pgrx=0.12.9


Availability

PG17PG16PG15PG14PG13
el8.x86_64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
el8.aarch64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
el9.x86_64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
el9.aarch64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
d12.x86_64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
d12.aarch64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
u22.x86_64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
u22.aarch64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
u24.x86_64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
u24.aarch64
2.10.0
2.10.0
2.10.0
2.10.0
2.10.0
CONTRIB
PGDG
PIGSTY

Download

To add the required PGDG / PIGSTY upstream repository, use:

pig repo add pgdg -u    # add PGDG repo and update cache (leave existing repos)
pig repo add pigsty -u  # add PIGSTY repo and update cache (leave existing repos)
pig repo add pgsql -u   # add PGDG + Pigsty repo and update cache (leave existing repos)
pig repo set all -u     # set repo to all = NODE + PGSQL + INFRA  (remove existing repos)
./node.yml -t node_repo -e node_repo_modules=node,pgsql # -l <cluster>

Or download the latest packages directly:


Install

Install this extension with:

pig ext install pgml; # install by extension name, for the current active PG version

pig ext install pgml -v 17;   # install for PG 17
pig ext install pgml -v 16;   # install for PG 16
pig ext install pgml -v 15;   # install for PG 15
pig ext install pgml -v 14;   # install for PG 14
dnf install pgml_17;
dnf install pgml_16;
dnf install pgml_15;
dnf install pgml_14;
apt install postgresql-17-pgml;
apt install postgresql-16-pgml;
apt install postgresql-15-pgml;
apt install postgresql-14-pgml;
./pgsql.yml -t pg_ext -e '{"pg_extensions": ["pgml"]}' # -l <cls>

Preload this extension with:

shared_preload_libraries = 'pgml'; # add to pg cluster config

Create this extension with:

CREATE EXTENSION pgml;

Usage

This extension is lack of maintenance

The PGML team seems not maintaining this extension for a while.

After installing the pgml extension and python dependencies on all cluster nodes, you can enable pgml on the PostgreSQL cluster.

Configure cluster with patronictl command and add pgml to shared_preload_libraries, and specify your venv dir in pgml.venv:

shared_preload_libraries: pgml, timescaledb, pg_stat_statements, auto_explain
pgml.venv: '/data/pgml'

After that, restart database cluster, and create extension with SQL command:

CREATE EXTENSION vector;        -- nice to have pgvector installed too!
CREATE EXTENSION pgml;          -- create PostgresML in current database
SELECT pgml.version();          -- print PostgresML version string

If it works, you should see something like:

# create extension pgml;
INFO:  Python version: 3.11.2 (main, Oct  5 2023, 16:06:03) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)]
INFO:  Scikit-learn 1.3.0, XGBoost 2.0.0, LightGBM 4.1.0, NumPy 1.26.1
CREATE EXTENSION

# SELECT pgml.version(); -- print PostgresML version string
 version
---------
 2.7.8

You are all set! Check PostgresML for more details: https://postgresml.org/docs/guides/use-cases/