Mid-level Track Roadmap

Database: GIN indexes & JSONB

This course follows one app's catalogue search, which filtered jsonb title columns with ILIKE while GIN indexes on those columns went unused. It shows how an operator class decides which operators a GIN index can serve. The default jsonb_ops has no support for LIKE or ILIKE, while pg_trgm's gin_trgm_ops indexes three-character pieces of text. Later lessons cover expression indexes that must match the query character for character and the measured size tradeoff between jsonb_ops and jsonb_path_ops. It ends with the fix: two indexes replaced, two unused ones dropped.

What you'll learn

  • ✓How a GIN operator class decides which operators an index can serve
  • ✓What the default jsonb_ops indexes and which six operators it registers
  • ✓Indexing ILIKE searches on extracted jsonb text with pg_trgm and gin_trgm_ops
  • ✓Writing expression indexes that match the query's expression character for character
  • ✓Comparing jsonb_ops and jsonb_path_ops on index size and supported operators
  • ✓Removing GIN indexes on columns that no query filters on
Free preview · Lesson 1 3 min read

A real GIN index, and a query that never touched it

Catalog::SearchQuery is the class behind this app's catalogue search. Until 2 September 2026, it filtered courses and lessons like this:

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...