Pg_re2: Postgres extension for fast, RE2-powered regular expressions in Postgres

Postgres gets a speed boost, and the comments instantly turned into an engine war

TLDR: ClickHouse released pg_re2, a Postgres add-on that speeds up text matching and search, with benchmarks showing clear wins over the built-in option. In the comments, the mood quickly shifted from praise to nerdy one-upmanship as people argued the bigger story is the growing arsenal of search engines.

A new tool called pg_re2 just landed for Postgres, the popular database software, promising much faster text pattern searches. The big claim? In ClickHouse’s tests, it beat Postgres’s built-in regex tools every time, sometimes by a lot. For regular people: this is basically a way to search messy text faster, which matters when your database is huge and every second counts. The company is also pitching it as a compatibility play, making Postgres behave more like ClickHouse in how it handles these searches.

But the real entertainment was the community reaction, which immediately swerved from “nice speedup” into full-on engine-flexing. Instead of simply applauding the benchmark wins, one commenter kicked open the door with a classic tech-world move: actually, ClickHouse also has even more regex engines. That turned the mood from product announcement to subtweet energy, with the vibe of, “Cute extension, but let’s not pretend this is the whole story.” It’s the kind of comment that says a lot with very few words: yes, the speed gains are cool, but some readers clearly see this as just one piece of a much bigger performance arms race.

The hottest opinion wasn’t really anti-pg_re2 at all—it was more of a power-user brag parade. The joke lurking under the thread was basically that database people can’t just enjoy a faster feature; they have to turn it into a leaderboard, complete with bonus points for saying things like “LLVM-JIT compiled regexp engine” as if that’s casual small talk. In other words: the software got faster, and the comments got deliciously more competitive.

Key Points

  • ClickHouse introduced pg_re2, a PostgreSQL extension that adds RE2-based regular expressions and is available via PGXN, GitHub, and ClickHouse Managed Postgres.
  • The article says pg_re2 was built for two main reasons: faster regex execution and better compatibility with ClickHouse regular expression functions.
  • It explains that PostgreSQL POSIX regexes use backtracking, while RE2 uses finite automata, which the article says provides stronger execution-time guarantees.
  • Benchmarks on an AWS m6g.2xlarge instance with PostgreSQL 18 showed pg_re2 outperforming native Postgres regex functions by 1.8x to 8.6x, and indexed operations by 1.1x to 1.8x.
  • pg_re2 v0.4.0 adds an @~ matching operator and btree and GIN index support, including gin_re2_ops for patterns that can avoid full table scans in cases where pg_trgm may not.

Hottest takes

"also has vectorscan as a regexp engine" — zX41ZdbW
"supporting multi- and fuzzy-matching" — zX41ZdbW
"the new LLVM-JIT compiled regexp engine" — zX41ZdbW
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.