I have a database that will have 1m+ records of the following shape:
create table simplified(
url text primary key, -- google.com/search?=something
url_host text not null, -- google.com
url_path text not null -- /search?=something
)
I understand that to search for a urls substr a simple query could be:
select * from simplified where url like '%google%'
I am trying to optimize for speed of search and am willing to form the data in anyway. Some questions I have:
- Is the
LIKE
operator really what I want for speed? or is there a faster alternative? - Can
tsvector
ortsquery
be implemented with aGIN
index in a meaningful way for single string search? - If not #2 is there something similar?
Thank you for your time in advance.
I have tried tsvector implementations to no avail, and some research on the topic.
2
Check the pg_trgm extension, that supports similarity searches using LIKE, ILIKE and (some) regexes.
0