Extensions/Modules in Postgres?

A extension is a modular package of SQL objects, functions, and compiled code that adds extra features or capabilities to your database that aren't available in the core distribution

What is pg_trgm/Trigram/Trigraph module

What is Alphanumeric text?
Alpha(alphabet) and numeric(number).
This character set that includes both letters (A-Z, both uppercase and lowercase) and numbers (0-9).
It can also include punctuation marks and other special symbols (like @, #, or &)
Eg: 3B9-XF4

What is a trigram?

Trigram is a contigous sequence of 3 or less characters taken from a string.
Each word is considered to have two spaces prefixed and one space suffixed when determining the set of trigrams contained in the string.
String Trigrams
"cat" “ c”, “ ca”, “cat”, and “at ”
“foo|bar” “ f”, “ fo”, “foo”, “oo ”, “ b”, “ ba”, “bar”, and “ar ”

Functions provided by pg_trgm module

Function Description
similarity ( text, text ) → real Returns a number that indicates how similar the two arguments are. The range of the result is zero (indicating that the two strings are completely dissimilar) to one (indicating that the two strings are identical).

# SELECT word_similarity('word', 'two words');
 word_similarity
-----------------
             0.8

"word"      trigrams {" w"," wo","wor","ord","rd "}
"two words" trigrams {" t"," tw","two","wo "," w"," wo","wor","ord","rds","ds "}
Similar trigrams     {" w"," wo","wor","ord"}
            
word_similarity ( text, text ) → real Returns a number that indicates the greatest similarity between the set of trigrams in the first string and any continuous extent of an ordered set of trigrams in the second string.

Operators provided by pg_trgm module

Operator Description
text % text → boolean Returns true if its arguments have a similarity that is greater than the current similarity threshold set by pg_trgm.similarity_threshold.
GiST and GIN index operator pg_trgm module provides GiST and GIN index operator classes that allow you to create an index over a text column for the purpose of very fast similarity searches.

CREATE TABLE test_trgm (t text);
CREATE INDEX trgm_idx ON test_trgm USING GIST (t gist_trgm_ops);
OR
CREATE INDEX trgm_idx ON test_trgm USING GIN (t gin_trgm_ops);