Skip to content

pg_bigmr

text similarity measurement and index searching based on bigrams

pg_bigmr · text similarity measurement and index searching based on bigrams

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100816pg_bigmrpg_bigmr0.1.0FTSPostgreSQLRust

PostgreSQL · 12, 13, 14, 15, 16, 17

Usage

Sources:

pg_bigmr 0.1.0 is an experimental Rust and pgrx reimplementation of pg_bigm. It provides bigram-based text similarity and a GIN operator class for accelerating LIKE and similarity searches, but upstream explicitly labels it work in progress.

Core Workflow

Add the module to shared_preload_libraries, restart PostgreSQL, create the extension, and build a GIN index with gin_bigm_ops.

shared_preload_libraries = 'pg_bigmr'
CREATE EXTENSION pg_bigmr;

CREATE INDEX documents_body_bigm_idx
  ON documents USING gin (body gin_bigm_ops);

SELECT * FROM documents WHERE body LIKE '%database%';
SELECT bigm_similarity('database', 'databass');

show_bigm(text) displays extracted bigrams, likequery(text) escapes a literal for contains-style LIKE, and pg_gin_pending_stats(oid) reports pending-list pages and tuples for a GIN index. The =% operator applies the similarity threshold.

Settings and Caveats

pg_bigmr.similarity_limit defaults to 0.3, pg_bigmr.gin_key_limit defaults to no limit, and pg_bigmr.enable_recheck defaults to on. Changing limits or disabling heap rechecks can trade correctness or selectivity for speed. This is not a drop-in assurance of pg_bigm compatibility; benchmark representative text, verify Unicode and wildcard behavior, and avoid production use without workload-specific validation.

Table reader