HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlCritical

How to install the additional module pg_trgm

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
installthemodulepg_trgmhowadditional

Problem

I just want to know how to install the module pg_tgrm as used in the trigram indexing scheme that allows you to do un-anchored search patterns on an index.

WHERE foo LIKE '%bar%';

Solution

pg_trgm is an extension, so:

CREATE EXTENSION pg_trgm;


If you get the following error

ERROR: could not open extension control file ".../extension/pg_trgm.control":

No such file or directory"

then you need to install the module for your operating system. For example:

-
Ubuntu/Debian:

sudo apt install postgresql-contrib


-
Redhat/Centos

sudo dnf install postgresql12-contrib


-
Fedora

sudo dnf install postgresql-contrib


-
FreeBSD

sudo pkg install postgresql12-contrib


Of course, "12" can be replaced with whatever version number is appropriate.

Code Snippets

CREATE EXTENSION pg_trgm;
sudo apt install postgresql-contrib
sudo dnf install postgresql12-contrib
sudo dnf install postgresql-contrib
sudo pkg install postgresql12-contrib

Context

StackExchange Database Administrators Q#165300, answer score: 78

Revisions (0)

No revisions yet.