Hash, GIN, GiST, SP-GiST, and BRIN each address workloads that B-tree handles poorly. A Hash index supports only equality (=) comparisons using a hash of the key. Since PostgreSQL 10, Hash indexes are WAL-logged and therefore crash-safe, and they are sometimes chosen over B-trees for very large tables where equality lookups occur on wide keys (long strings or UUIDs) because they can be slightly smaller. They remain useless for range queries or ordering.
GIN stands for Generalized Inverted Index and is designed for values that contain many sub-elements: arrays, JSONB documents, full-text tsvectors, and trigrams. The operator class dictates what is indexed; for JSONB, jsonb_ops indexes every key and value and supports the existence operators (?, ?|, ?&) as well as containment (@>), while jsonb_path_ops indexes only the paths to values, supports only @>, and is smaller and faster for containment-only queries. GIN maintains a pending list of recent updates for speed; VACUUM flushes this list, and the fastupdate option (on by default) controls the trade-off.
GiST, the Generalized Search Tree, is a balanced structure that hosts many search strategies including range overlap (&&), nearest-neighbor searches (<->), geometry and full-text types, and exclusion constraints. SP-GiST, the Space-Partitioned variant, handles non-balanced data such as quadtrees, kd-trees, and radix trees, useful for phone numbers, IP addresses via the inet type, and geometric point data. BRIN, Block Range INdex, takes a fundamentally different approach: it stores a summary (typically min/max, optionally other aggregates) for each range of heap pages, making it tiny in size. BRIN shines on very large append-only tables where data is naturally correlated with physical order, such as monotonically increasing timestamps in time-series logs, but performs poorly on tables with random inserts and updates because the correlations it relies on break down. The pages_per_range parameter tunes the granularity: smaller values produce more accurate and larger indexes, larger values produce more compact but coarser ones.