NEW RasterizedDB 1.1.0 is out: sharding and the gateway, the message broker, roles and row-level security, compression, .NET on NuGet, and the enterprise edition. What's new ›
JSON & SEARCH

Documents and text, beside your rows.

JSON and JSONB columns, indexed by path or whole, full-text search over a GIN index, and case- and accent-insensitive collations, all inside the same transactions as the relational data.

1 / 4

Two ways to store a document

By default a JSONB column stores the document as a binary value. Turn on shadow tables and each key becomes a real column of its own table instead, so the filter index and zone maps see every field: WHERE doc->>'hits' > 10 is planned like a declared column.

  • Binary JSONB: any shape, keys driven by data
  • Shadow tables: typed columns per key, widened when a later document disagrees, never losing a value
  • Chosen with one knob: --json-shadow-tables
2 / 4

Indexes for documents

SQL
CREATE INDEX events_doc ON events USING gin (doc);                  -- jsonb_ops
CREATE INDEX events_path ON events USING gin (doc jsonb_path_ops);
CREATE INDEX events_user ON events ((doc->'user'->>'id'));          -- one field
3 / 4

Full-text search

MySQL's FULLTEXT keys and MATCH … AGAINST, and SQL Server's CONTAINS, are answered by the same index.

SQL
CREATE INDEX posts_fts ON posts USING gin (to_tsvector('english', body));
SELECT id FROM posts
 WHERE to_tsvector('english', body) @@ to_tsquery('english', 'rust & database');
4 / 4

Collations that ignore case, or accents

SQL
CREATE TABLE people (
  id    int PRIMARY KEY,
  name  text COLLATE rdb_ci NOT NULL UNIQUE,
  email citext,
  place text COLLATE rdb_ci_ai
);
SELECT id FROM people WHERE name = 'BOB';     -- finds 'Bob'
SELECT id FROM people WHERE place = 'cafe';   -- finds 'Café'
✓ page rendered in 149 µs axum + tera + htmx · no other javascript