Skip to content

onesparse

Sparse linear algebra and graph extension for PostgreSQL 18

one_sparse · Sparse linear algebra and graph extension for PostgreSQL 18

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2620onesparseone_sparse0.1.0FEATApache-2.0C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--NoYesYesYesnono
Relationships
Schemasonesparse
See Alsoage pg_liquid graph pgrdf ltree sparql
PG18; package 1.0.0 / SQL 0.1.0; preload onesparse. Rebuilt with GraphBLAS 10.5.2 and LAGraph 1.2.2.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.1.019 18 17 16 15one_sparse-
RPMPIGSTY1.0.019 18 17 16 15onesparse_$vgraphblas, lagraph
DEBPIGSTY1.0.019 18 17 16 15postgresql-$v-onesparselibgraphblas10, liblagraph1, liblagraphx1
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0.0N/AN/AN/A
el8.aarch64N/APIGSTY 1.0.0N/AN/AN/A
el9.x86_64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
el9.aarch64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
el10.x86_64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
el10.aarch64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
d12.x86_64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
d12.aarch64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
d13.x86_64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
d13.aarch64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
u22.x86_64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
u22.aarch64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
u24.x86_64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
u24.aarch64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
u26.x86_64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
u26.aarch64PIGSTY 1.0.0PIGSTY 1.0.0N/AN/AN/A
PackageVersionOSORGSIZEFile URL
onesparse_191.0.0el9.x86_64pigsty675.8 KiBonesparse_19-1.0.0-2PGSTY.el9.x86_64.rpm
onesparse_191.0.0el9.aarch64pigsty665.9 KiBonesparse_19-1.0.0-2PGSTY.el9.aarch64.rpm
onesparse_191.0.0el10.x86_64pigsty687.0 KiBonesparse_19-1.0.0-2PGSTY.el10.x86_64.rpm
onesparse_191.0.0el10.aarch64pigsty673.3 KiBonesparse_19-1.0.0-2PGSTY.el10.aarch64.rpm
postgresql-19-onesparse1.0.0d12.x86_64pigsty596.4 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~bookworm_amd64.deb
postgresql-19-onesparse1.0.0d12.aarch64pigsty577.3 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~bookworm_arm64.deb
postgresql-19-onesparse1.0.0d13.x86_64pigsty592.7 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~trixie_amd64.deb
postgresql-19-onesparse1.0.0d13.aarch64pigsty576.7 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~trixie_arm64.deb
postgresql-19-onesparse1.0.0u22.x86_64pigsty695.4 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~jammy_amd64.deb
postgresql-19-onesparse1.0.0u22.aarch64pigsty683.5 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~jammy_arm64.deb
postgresql-19-onesparse1.0.0u24.x86_64pigsty645.6 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~noble_amd64.deb
postgresql-19-onesparse1.0.0u24.aarch64pigsty634.8 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~noble_arm64.deb
postgresql-19-onesparse1.0.0u26.x86_64pigsty658.2 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~resolute_amd64.deb
postgresql-19-onesparse1.0.0u26.aarch64pigsty642.0 KiBpostgresql-19-onesparse_1.0.0-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
onesparse_181.0.0el8.x86_64pigsty677.0 KiBonesparse_18-1.0.0-2PGSTY.el8.x86_64.rpm
onesparse_181.0.0el8.aarch64pigsty656.3 KiBonesparse_18-1.0.0-2PGSTY.el8.aarch64.rpm
onesparse_181.0.0el9.x86_64pigsty675.7 KiBonesparse_18-1.0.0-2PGSTY.el9.x86_64.rpm
onesparse_181.0.0el9.aarch64pigsty666.1 KiBonesparse_18-1.0.0-2PGSTY.el9.aarch64.rpm
onesparse_181.0.0el10.x86_64pigsty687.1 KiBonesparse_18-1.0.0-2PGSTY.el10.x86_64.rpm
onesparse_181.0.0el10.aarch64pigsty673.4 KiBonesparse_18-1.0.0-2PGSTY.el10.aarch64.rpm
postgresql-18-onesparse1.0.0d12.x86_64pigsty601.4 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~bookworm_amd64.deb
postgresql-18-onesparse1.0.0d12.aarch64pigsty576.6 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~bookworm_arm64.deb
postgresql-18-onesparse1.0.0d13.x86_64pigsty595.9 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~trixie_amd64.deb
postgresql-18-onesparse1.0.0d13.aarch64pigsty576.3 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~trixie_arm64.deb
postgresql-18-onesparse1.0.0u22.x86_64pigsty695.0 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~jammy_amd64.deb
postgresql-18-onesparse1.0.0u22.aarch64pigsty683.3 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~jammy_arm64.deb
postgresql-18-onesparse1.0.0u24.x86_64pigsty646.0 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~noble_amd64.deb
postgresql-18-onesparse1.0.0u24.aarch64pigsty634.5 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~noble_arm64.deb
postgresql-18-onesparse1.0.0u26.x86_64pigsty658.1 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~resolute_amd64.deb
postgresql-18-onesparse1.0.0u26.aarch64pigsty642.3 KiBpostgresql-18-onesparse_1.0.0-2PGSTY~resolute_arm64.deb

Source

pig build pkg one_sparse;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

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

Install this extension with pig:

pig install one_sparse;		# install by package name
pig install onesparse;		# install by extension name

pig install onesparse -v 19;   # install for PG 19
pig install onesparse -v 18;   # install for PG 18

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'onesparse';

Create this extension with:

CREATE EXTENSION onesparse;

Usage

Sources: homepage, release v1.0.0, control file at v1.0.0, intro docs, matrix docs, vector docs, algorithm examples

OneSparse is a PostgreSQL extension that binds SuiteSparse:GraphBLAS into Postgres and exposes sparse linear algebra and graph algorithms as new types, functions, and operators. The docs treat matrix as the core type, with vector and scalar built on top of the same model. The v1.0.0 release exists, while the extension control file at that tag still declares SQL default_version = '0.1.0'.

Core Setup

CREATE EXTENSION onesparse;
SET search_path TO public,onesparse;

SELECT 'int32'::matrix;
SELECT 'int32'::vector;
SELECT 'int32:42'::scalar;

The docs site organizes the API around matrix, vector, and scalar, with interactive examples using casts and constructors.

Matrix and Vector

The matrix page shows common operations such as construction, print(), draw(), assignment, extraction, cast_to(), resize, and aggregation. The vector page documents the matching vector API including nvals(), size(), eadd(), emult(), reduce_scalar(), choose(), and apply().

SELECT print('int32(4:4)'::matrix);
SELECT draw('int32(4:4)[1:2:1 2:3:2 3:1:3]'::matrix);
SELECT eadd('int32[0:1 1:2 2:3]'::vector, 'int32[0:1 1:2 2:3]'::vector, 'plus_int32');
SELECT reduce_scalar('int32[0:1 1:2 2:3]'::vector, 'plus_monoid_int32');

Graph Algorithms

The examples page uses Matrix Market input and graph visualization with draw(...). The documented graph algorithms include:

  • bfs(graph, 1) for level and parent BFS
  • sssp(cast_to(graph, 'int32'), 1::bigint, 1) for single-source shortest path
  • pagerank(graph) for ranking vertices by link structure
  • triangle_centrality(graph) for triangle-based centrality
  • betweenness(graph, ARRAY[...]) and square_clustering(graph) for additional graph analysis

Representative example from the docs:

SELECT draw(triu(graph), (SELECT level FROM bfs(graph, 1)), false, false, true, 0.5)
FROM karate;

The same guide shows loading a graph with mmread('/home/postgres/onesparse/demo/karate.mtx').

Table reader