ELSEIF
Your brief EB
386 stories from 200 feeds 1260 clusters Refreshed 12 minutes ago next pull 12:31

DATABASES Signal 154

pg_tre and pg_re2 bring new regex index options to PostgreSQL but pg_trgm still wins for simple patterns

Illustration only Photo by Brecht Corbeel on Unsplash

A PostgreSQL engineer benchmarked two newer regex extensions, pg_tre and pg_re2, against the established pg_trgm, finding that pg_tre's index is dramatically larger and slower to build while offering no advantage for simple substring searches.

WHY IT MATTERS

If you rely on regex searches over large text columns in PostgreSQL, pg_trgm remains the practical default for simple patterns. pg_tre may offer value for more complex regex matching, but it comes with a 21 GB index on a 33 GB table and a 7-hour build time, so adoption requires careful evaluation of whether your queries actually need what it provides.

Written by elseif from the cluster below · every claim links back to a source

The three things worth knowing

01

pg_tre built a 21 GB index on 1.6 million rows (~33 GB of text) in over 7 hours, compared to pg_trgm's 1667 MB index built in roughly 17 minutes.

02

For a simple substring search, pg_trgm returned results in 1.6 seconds while pg_tre took 2.3 seconds, and pg_tre's own documentation recommends pg_trgm for exact substring and LIKE queries.

03

The article was cut off before testing more complex regex patterns where pg_tre might justify its cost, and pg_re2 was not benchmarked in the available material.

THE CLUSTER

Same story, 1 feed.

ORDERED BY FIRST SEEN
depesz.com via Lobsters New things for regular expressions in PostgreSQL (pg_tre and pg_re2) Open ↗