Skip to content

PGlite Extensions

PGlite supports both Postgres extensions, and has a plugin API to enable extensions to extend the public API of the PGlite interface.

Below is a list of available extensions.

live

A reactive, or "live", query extension for PGlite that enables you to subscribe to a query and receive updated results when the underlying tables change.

live is included in the main PGlite package.

js
import { live } from '@electric-sql/pglite/live';
const pg = new PGlite({
  extensions: { live }
});
pglite plugin

pgvector

Open-source vector similarity search for Postgres.

Store your vectors with the rest of your data. Supports:

  • exact and approximate nearest neighbor search
  • single-precision, half-precision, binary, and sparse vectors
  • L2 distance, inner product, cosine distance, L1 distance, Hamming distance, and Jaccard distance

pgvector is included in the main PGlite package.

js
import { vector } from '@electric-sql/pglite/vector';
const pg = new PGlite({
  extensions: { vector }
});
postgres extension

adminpack

adminpack provides a number of support functions which pgAdmin and other administration and management tools can use to provide additional functionality

adminpack is included in the main PGlite package.

js
import { adminpack } from '@electric-sql/pglite/contrib/adminpack';
const pg = new PGlite({
  extensions: { adminpack }
});
postgres extensionpostgres/contrib

amcheck

The amcheck module provides functions that allow you to verify the logical consistency of the structure of relations.

amcheck is included in the main PGlite package.

js
import { amcheck } from '@electric-sql/pglite/contrib/amcheck';
const pg = new PGlite({
  extensions: { amcheck }
});
postgres extensionpostgres/contrib

auto_explain

The auto_explain module provides a means for logging execution plans of slow statements automatically, without having to run EXPLAIN by hand.

auto_explain is included in the main PGlite package.

js
import { auto_explain } from '@electric-sql/pglite/contrib/auto_explain';
const pg = new PGlite({
  extensions: { auto_explain }
});
postgres extensionpostgres/contrib

bloom

bloom provides an index access method based on Bloom filters. A Bloom filter is a space-efficient data structure that is used to test whether an element is a member of a set. In the case of an index access method, it allows fast exclusion of non-matching tuples via signatures whose size is determined at index creation.

bloom is included in the main PGlite package.

js
import { bloom } from '@electric-sql/pglite/contrib/bloom';
const pg = new PGlite({
  extensions: { bloom }
});
postgres extensionpostgres/contrib

btree_gin

btree_gin provides GIN operator classes that implement B-tree equivalent behavior for many built in data types.

btree_gin is included in the main PGlite package.

js
import { btree_gin } from '@electric-sql/pglite/contrib/btree_gin';
const pg = new PGlite({
  extensions: { btree_gin }
});
postgres extensionpostgres/contrib

btree_gist

btree_gist provides GiST operator classes that implement B-tree equivalent behavior for many built in data types.

btree_gist is included in the main PGlite package.

js
import { btree_gist } from '@electric-sql/pglite/contrib/btree_gist';
const pg = new PGlite({
  extensions: { btree_gist }
});
postgres extensionpostgres/contrib

citext

citext provides a case-insensitive character string type, citext. Essentially, it internally calls lower when comparing values. Otherwise, it behaves almost the same as text.

citext is included in the main PGlite package.

js
import { citext } from '@electric-sql/pglite/contrib/citext';
const pg = new PGlite({
  extensions: { citext }
});
postgres extensionpostgres/contrib

cube

cube provides a data type cube for representing multidimensional cubes.

cube is included in the main PGlite package.

js
import { cube } from '@electric-sql/pglite/contrib/cube';
const pg = new PGlite({
  extensions: { cube }
});
postgres extensionpostgres/contrib

earthdistance

The earthdistance module provides tools for calculating great circle distances on the surface of the Earth.

earthdistance is included in the main PGlite package.

js
import { earthdistance } from '@electric-sql/pglite/contrib/earthdistance';
const pg = new PGlite({
  extensions: { earthdistance }
});
postgres extensionpostgres/contrib

fuzzystrmatch

fuzzystrmatch provides functions to determine similarities and distance between strings.

fuzzystrmatch is included in the main PGlite package.

js
import { fuzzystrmatch } from '@electric-sql/pglite/contrib/fuzzystrmatch';
const pg = new PGlite({
  extensions: { fuzzystrmatch }
});
postgres extensionpostgres/contrib

hstore

This module implements the hstore data type for storing sets of key/value pairs within a single PostgreSQL value. This can be useful in various scenarios, such as rows with many attributes that are rarely examined, or semi-structured data. Keys and values are simply text strings.

hstore is included in the main PGlite package.

js
import { hstore } from '@electric-sql/pglite/contrib/hstore';
const pg = new PGlite({
  extensions: { hstore }
});
postgres extensionpostgres/contrib

isn

The isn module provides data types for the following international product numbering standards: EAN13, UPC, ISBN (books), ISMN (music), and ISSN (serials).

isn is included in the main PGlite package.

js
import { isn } from '@electric-sql/pglite/contrib/isn';
const pg = new PGlite({
  extensions: { isn }
});
postgres extensionpostgres/contrib

lo

The lo module provides support for managing Large Objects (also called LOs or BLOBs). This includes a data type lo and a trigger lo_manage.

lo is included in the main PGlite package.

js
import { lo } from '@electric-sql/pglite/contrib/lo';
const pg = new PGlite({
  extensions: { lo }
});
postgres extensionpostgres/contrib

ltree

This module implements a data type ltree for representing labels of data stored in a hierarchical tree-like structure. Extensive facilities for searching through label trees are provided.

ltree is included in the main PGlite package.

js
import { ltree } from '@electric-sql/pglite/contrib/ltree';
const pg = new PGlite({
  extensions: { ltree }
});
postgres extensionpostgres/contrib

pg_trgm

The pg_trgm module provides functions and operators for determining the similarity of alphanumeric text based on trigram matching, as well as index operator classes that support fast searching for similar strings.

pg_trgm is included in the main PGlite package.

js
import { pg_trgm } from '@electric-sql/pglite/contrib/pg_trgm';
const pg = new PGlite({
  extensions: { pg_trgm }
});
postgres extensionpostgres/contrib

seg

This module implements a data type seg for representing line segments, or floating point intervals. seg can represent uncertainty in the interval endpoints, making it especially useful for representing laboratory measurements.

seg is included in the main PGlite package.

js
import { seg } from '@electric-sql/pglite/contrib/seg';
const pg = new PGlite({
  extensions: { seg }
});
postgres extensionpostgres/contrib

tablefunc

The tablefunc module includes various functions that return tables (that is, multiple rows). These functions are useful both in their own right and as examples of how to write C functions that return multiple rows.

tablefunc is included in the main PGlite package.

js
import { tablefunc } from '@electric-sql/pglite/contrib/tablefunc';
const pg = new PGlite({
  extensions: { tablefunc }
});
postgres extensionpostgres/contrib

tcn

The tcn module provides a trigger function that notifies listeners of changes to any table on which it is attached. It must be used as an AFTER trigger FOR EACH ROW.

tcn is included in the main PGlite package.

js
import { tcn } from '@electric-sql/pglite/contrib/tcn';
const pg = new PGlite({
  extensions: { tcn }
});
postgres extensionpostgres/contrib

tsm_system_rows

The tsm_system_rows module provides the table sampling method SYSTEM_ROWS, which can be used in the TABLESAMPLE clause of a SELECT command.

tsm_system_rows is included in the main PGlite package.

js
import { tsm_system_rows } from '@electric-sql/pglite/contrib/tsm_system_rows';
const pg = new PGlite({
  extensions: { tsm_system_rows }
});
postgres extensionpostgres/contrib

tsm_system_time

The tsm_system_time module provides the table sampling method SYSTEM_TIME, which can be used in the TABLESAMPLE clause of a SELECT command.

js
import { tsm_system_time } from '@electric-sql/pglite/contrib/tsm_system_time';
const pg = new PGlite({
  extensions: { tsm_system_time }
});
postgres extensionpostgres/contrib

uuid-ossp

The uuid-ossp module provides functions to generate universally unique identifiers (UUIDs) using one of several standard algorithms. There are also functions to produce certain special UUID constants. This module is only necessary for special requirements beyond what is available in core PostgreSQL.

js
import { uuid_ossp } from '@electric-sql/pglite/contrib/uuid_ossp';
const pg = new PGlite({
  extensions: { uuid_ossp }
});
postgres extensionpostgres/contrib