Skip to content

tin

TIN-compatible text search for development and testing

Overview

PackageVersionCategoryLicenseLanguage
lead1.0.6FTSAGPL-3.0-or-laterRust
IDExtensionBinLibLoadCreateTrustRelocSchema
2310tinNoYesNoYesNoNotin

Untagged 1.0.6 source snapshot for development/CI, not production PlanetScale TIN. Conflicts with stannum in the same database.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.0.61817161514lead-
RPMPIGSTY1.0.61817161514lead_$v-
DEBPIGSTY1.0.61817161514postgresql-$v-lead-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64N/AN/AN/A
el8.aarch64N/AN/AN/A
el9.x86_64N/AN/AN/A
el9.aarch64N/AN/AN/A
el10.x86_64N/AN/AN/A
el10.aarch64N/AN/AN/A
d12.x86_64N/AN/AN/A
d12.aarch64N/AN/AN/A
d13.x86_64N/AN/AN/A
d13.aarch64
PIGSTY 1.0.6
PIGSTY 1.0.6
N/AN/AN/A
u22.x86_64
PIGSTY 1.0.6
PIGSTY 1.0.6
N/AN/AN/A
u22.aarch64
PIGSTY 1.0.6
PIGSTY 1.0.6
N/AN/AN/A
u24.x86_64
PIGSTY 1.0.6
PIGSTY 1.0.6
N/AN/AN/A
u24.aarch64
PIGSTY 1.0.6
PIGSTY 1.0.6
N/AN/AN/A
u26.x86_64N/AN/AN/A
u26.aarch64N/AN/AN/A

Build

You can build the RPM / DEB packages for lead using pig build:

pig build pkg lead         # build RPM / DEB packages

Install

You can install lead 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:

Install
pig install lead;          # Install for current active PG version
pig
pig ext install -y lead -v 18  # PG 18
pig ext install -y lead -v 17  # PG 17
dnf
dnf install -y lead_18       # PG 18
dnf install -y lead_17       # PG 17
apt
apt install -y postgresql-18-lead   # PG 18
apt install -y postgresql-17-lead   # PG 17

Create Extension:

CREATE EXTENSION tin;

Usage

Sources:

tin is the extension name of Lead, a TIN-compatible text-search implementation for development, CI, and staging. The reviewed 1.0.6 source snapshot deliberately trades performance for a small reference implementation and is unsuitable for production search.

Core Workflow

CREATE EXTENSION tin;
CREATE TABLE documents (id integer, body text);
INSERT INTO documents VALUES (1, 'craft beer'), (2, 'wine'), (3, 'beer festival');
CREATE INDEX documents_search ON documents USING tin (body);
SELECT id, tin.full_score(ctid) AS score
FROM documents WHERE body ==> 'beer' ORDER BY score DESC;

Objects and Behavior

The tin access method and ==> operator evaluate TINQL predicates. tin.score, tin.full_score, tin.max_score, and tin.score_inspect expose scoring; tin.highlight and tin.highlight_ansi mark matches. Scoring calls bind to the matching search expression and index.

Every index scan returns all heap pages as lossy candidates. PostgreSQL rechecks the visible tuples, expressions, and partial-index predicates. The index stores no search data; scoring may rescan visible heap rows. This preserves query semantics without providing a production inverted index.

Requirements

The reviewed source targets PostgreSQL 17 and 18. Installation requires a superuser; objects use the fixed tin schema. The library loads on demand and needs no preload or restart. Keep realistic data volumes in mind when using it in tests.

PlanetScale documents TIN as its production search implementation and Lead as the local development substitute. Both use the canonical extension name tin; this catalog entry tracks the open-source Lead implementation. Its source-snapshot version is not a claim about the version deployed by PlanetScale.

The current source adds a trailing stemmer argument to tin.tokenize, tin.ql_parse, tin.highlight, and tin.highlight_ansi, while keeping the earlier signatures under names ending in _v1_0_3. Changing an index’s stemmer requires REINDEX. A score call must be at the same query level as its matching ==> predicate.

Was this page helpful?