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

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

dict_int

dict_int is an example of an add-on dictionary template for full-text search. The motivation for this example dictionary is to control the indexing of integers (signed and unsigned), allowing such numbers to be indexed while preventing excessive growth in the number of unique words, which greatly affects the performance of searching.

dict_int is included in the main PGlite package.

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

dict_xsyn

dict_xsyn (Extended Synonym Dictionary) is an example of an add-on dictionary template for full-text search. This dictionary type replaces words with groups of their synonyms, and so makes it possible to search for a word using any of its synonyms.

dict_xsyn is included in the main PGlite package.

js
import { dict_xsyn } from '@electric-sql/pglite/contrib/dict_xsyn';
const pg = new PGlite({
  extensions: { dict_xsyn }
});
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

file_fdw

The file_fdw module provides the foreign-data wrapper file_fdw, which can be used to access data files in the server's file system, or to execute programs on the server and read their output. The data file or program output must be in a format that can be read by COPY FROM. Access to data files is currently read-only.

file_fdw is included in the main PGlite package.

js
import { file_fdw } from '@electric-sql/pglite/contrib/file_fdw';
const pg = new PGlite({
  extensions: { file_fdw }
});
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

intarray

The intarray module provides a number of useful functions and operators for manipulating null-free arrays of integers. There is also support for indexed searches using some of the operators.

intarray is included in the main PGlite package.

js
import { intarray } from '@electric-sql/pglite/contrib/intarray';
const pg = new PGlite({
  extensions: { intarray }
});
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

pageinspect

The pageinspect module provides functions that allow you to inspect the contents of database pages at a low level, which is useful for debugging purposes. All of these functions may be used only by superusers.

pageinspect is included in the main PGlite package.

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

pg_buffercache

The pg_buffercache module provides a means for examining what's happening in the shared buffer cache in real time. It also offers a low-level way to evict data from it, for testing purposes.

pg_buffercache is included in the main PGlite package.

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

pg_freespacemap

The pg_freespacemap module provides a means for examining the free space map (FSM). It provides a function called pg_freespace, or two overloaded functions, to be precise. The functions show the value recorded in the free space map for a given page, or for all pages in the relation.

pg_freespacemap is included in the main PGlite package.

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

pg_ivm

The pg_ivm module provides Incremental View Maintenance (IVM) feature for PostgreSQL. Incremental View Maintenance (IVM) is a way to make materialized views up-to-date in which only incremental changes are computed and applied on views rather than recomputing the contents from scratch as REFRESH MATERIALIZED VIEW does. IVM can update materialized views more efficiently than recomputation when only small parts of the view are changed.

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

pg_surgery

The pg_surgery module provides various functions to perform surgery on a damaged relation. These functions are unsafe by design and using them may corrupt (or further corrupt) your database. For example, these functions can easily be used to make a table inconsistent with its own indexes, to cause UNIQUE or FOREIGN KEY constraint violations, or even to make tuples visible which, when read, will cause a database server crash. They should be used with great caution and only as a last resort.

pg_surgery is included in the main PGlite package.

js
import { pg_surgery } from '@electric-sql/pglite/contrib/pg_surgery';
const pg = new PGlite({
  extensions: { pg_surgery }
});
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

pg_visibility

The pg_visibility module provides a means for examining the visibility map (VM) and page-level visibility information of a table. It also provides functions to check the integrity of a visibility map and to force it to be rebuilt.

pg_visibility is included in the main PGlite package.

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

pg_walinspect

The pg_walinspect module provides SQL functions that allow you to inspect the contents of write-ahead log of a running PostgreSQL database cluster at a low level, which is useful for debugging, analytical, reporting or educational purposes. It is similar to pg_waldump, but accessible through SQL rather than a separate utility.

pg_walinspect is included in the main PGlite package.

js
import { pg_walinspect } from '@electric-sql/pglite/contrib/pg_walinspect';
const pg = new PGlite({
  extensions: { pg_walinspect }
});
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

unaccent

unaccent is a text search dictionary that removes accents (diacritic signs) from lexemes. It's a filtering dictionary, which means its output is always passed to the next dictionary (if any), unlike the normal behavior of dictionaries. This allows accent-insensitive processing for full text search.

unaccent is included in the main PGlite package.

js
import { unaccent } from '@electric-sql/pglite/contrib/unaccent';
const pg = new PGlite({
  extensions: { unaccent }
});
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