DEV Community

Discussion on: How to query with PostgreSQL wildcards like a Pro

Collapse
 
dmfay profile image
Dian Fay • Edited

Since you're running on Postgres, you can use ILIKE for a case-insensitive LIKE instead of multiple conditions! There are also a couple different flavors of regular expression which are even more flexible.

The leading wildcard makes your "full-text search" non-sargable and therefore likely to perform poorly on larger tables or text fields. For actual full-text search you'll want to use tsvectors and to_tsquery().

Collapse
 
igeligel profile image
Kevin Peters

Thanks, knew about ILIKE but this is just an extension for PostgreSQL. Regular expressions are of course more flexible. Also thanks for mentioning the full-text search. I will extend the article to include these points.