pg_bigm
create 2-gram (bigram) index for faster full text search.
pg_bigm : create 2-gram (bigram) index for faster full text search.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2120 | pg_bigm | pg_bigm | 1.2 |
FTS | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-r | No | Yes | Yes | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | pgroonga pg_cjk_parser pg_jieba zhparser pg_tokenizer pg_pinyin unaccent pg_trgm dict_xsyn biscuit |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 1.2 |
18 17 16 15 14 | pg_bigm |
- |
| RPM | PGDG | 1.2 |
18 17 16 15 14 | pg_bigm_$v |
- |
| DEB | PIGSTY | 1.2 |
18 17 16 15 14 | postgresql-$v-pg-bigm |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 |
| el8.aarch64 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 |
| el9.x86_64 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 |
| el9.aarch64 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 |
| el10.x86_64 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 |
| el10.aarch64 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 | PGDG 1.2 |
| d12.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| d12.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| d13.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| d13.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u22.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u22.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u24.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u24.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u26.x86_64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
| u26.aarch64 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 | PIGSTY 1.2 |
Source
github.com/pgbigm/pg_bigm
pg_bigm-1.2-20250903.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
The pg_bigm module provides full text search capability in PostgreSQL. This module allows a user to create 2-gram (bigram) index for faster full text search.
pg_bigm is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
Features
- Bigram indexing: Creates 2-gram (bigram) GIN indexes for text columns
- Faster LIKE searches: Accelerates
LIKEqueries including prefix, suffix, and substring searches - All language support: Works with any language including CJK (Chinese, Japanese, Korean) without additional configuration
- Simple API: Provides similarity search functions and operators
Functions and Operators
Functions
| Function | Return Type | Description |
|---|---|---|
likequery(text) |
text |
Generates a search query for full text search from a keyword |
show_bigm(text) |
text[] |
Shows all 2-grams in the given string |
pg_gin_pending_stats(regclass) |
record |
Returns the number of pages and tuples in the pending list of a GIN index |
Operators
| Operator | Description |
|---|---|
text =% text |
Returns true if the similarity between the left and right operands is greater than or equal to pg_bigm.similarity_limit |
GUC Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
pg_bigm.last_update |
text |
- | Shows the last update date of the module (read-only) |
pg_bigm.enable_recheck |
bool |
on |
Controls whether recheck is performed during index scan |
pg_bigm.gin_key_limit |
int |
0 |
Limits the maximum number of bigrams used for full text search. 0 means no limit |
pg_bigm.similarity_limit |
real |
0.3 |
Sets the minimum similarity threshold for the =% operator |
Examples
Basic Full Text Search
Similarity Search
Comparison with pg_trgm
pg_bigm has the following advantages over the built-in pg_trgm:
| Feature | pg_bigm | pg_trgm |
|---|---|---|
| N-gram type | 2-gram (bigram) | 3-gram (trigram) |
| Minimum search string | 1 character | 3 characters |
| Non-alphabetic languages | Full support | Limited support |
| LIKE search types | Prefix, suffix, and substring | Prefix, suffix, and substring |
For detailed documentation including advanced usage and performance tuning, see the official pg_bigm documentation.