rum
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
rum | 1.3.15 | FEAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2720 | rum | No | Yes | No | Yes | No | Yes | - |
| Related | pg_trgm btree_gist btree_gin pg_search pgroonga pg_bigm zhparser pgroonga_database |
|---|---|
| Depended By | documentdb |
1.3.15 build pass on pg 16,17,18
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | MIXED | 1.3.15 | 1817161514 | rum | - |
| RPM | PIGSTY | 1.3.15 | 1817161514 | rum_$v | - |
| DEB | PGDG | 1.3.15 | 1817161514 | postgresql-$v-rum | - |
Build
You can build the RPM packages for rum using pig build:
pig build pkg rum # build RPM packages
Install
You can install rum directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install rum; # Install for current active PG version
pig ext install -y rum -v 18 # PG 18
pig ext install -y rum -v 17 # PG 17
pig ext install -y rum -v 16 # PG 16
pig ext install -y rum -v 15 # PG 15
pig ext install -y rum -v 14 # PG 14
dnf install -y rum_18 # PG 18
dnf install -y rum_17 # PG 17
dnf install -y rum_16 # PG 16
dnf install -y rum_15 # PG 15
dnf install -y rum_14 # PG 14
apt install -y postgresql-18-rum # PG 18
apt install -y postgresql-17-rum # PG 17
apt install -y postgresql-16-rum # PG 16
apt install -y postgresql-15-rum # PG 15
apt install -y postgresql-14-rum # PG 14
Create Extension:
CREATE EXTENSION rum;
Usage
RUM is an index access method that extends GIN by storing additional information in the posting tree. This enables direct access to positional data, avoiding extra heap scans for ranking, phrase searches, and timestamp ordering.
Index Creation
CREATE INDEX idx ON table_name USING rum (column operator_class);
With addon operators (e.g., ordering by a timestamp alongside full-text search):
CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d)
WITH (attach = 'd', to = 't');
Operator Classes
| Operator Class | Description |
|---|---|
rum_tsvector_ops | Stores tsvector lexemes with positions. Supports <=> ordering and prefix search. |
rum_tsvector_hash_ops | Stores hashed tsvector lexemes with positions. Supports <=> ordering, no prefix search. |
rum_tsvector_addon_ops | Combines tsvector with additional fields (timestamps, integers, etc.) for filtering and ordering. |
rum_tsvector_hash_addon_ops | Hashed variant supporting addon fields, no prefix search. |
rum_tsquery_ops | Stores tsquery branches for fast query matching against indexed documents. |
rum_anyarray_ops | Indexes array types. Supports &&, @>, <@, =, % and <=> ordering. |
rum_anyarray_addon_ops | Combines array elements with additional fields. |
rum_TYPE_ops | Generic ops for int2, int4, int8, float4, float8, money, oid, time, timetz, date, interval, macaddr, inet, cidr, text, varchar, char, bytea, bit, varbit, numeric, timestamp, timestamptz. |
Ordering Operators
| Operator | Description |
|---|---|
<=> | Distance operator for tsvector, timestamp, numeric types, arrays |
<=| | Left-side distance for timestamp, int, float, money, oid |
|=> | Right-side distance for timestamp, int, float, money, oid |
Examples
Full-text search with ranking:
SELECT t, a <=> to_tsquery('english', 'beautiful | place') AS rank
FROM test_rum
WHERE a @@ to_tsquery('english', 'beautiful | place')
ORDER BY a <=> to_tsquery('english', 'beautiful | place');
Timestamp-ordered full-text search:
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts
WHERE t @@ 'wr&qh'
ORDER BY d <=> '2016-05-16 14:21:25'
LIMIT 5;
Array matching with distance ordering:
SELECT * FROM test_array
WHERE i && '{1}'
ORDER BY i <=> '{1}' ASC;
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.