I'm coding an Domain, URL and Regex (like SquidGuard) filter for Squid using the eCAP protocol and i want store all the domains into a postgresql database. The problem is that when i do a search with like, example:
SELECT website_groups.id,
"name",
description
FROM website_domains
JOIN website_groups ON website_group_id = website_groups.id
WHERE (website_domains.domain = 'google.com'
OR website_domains.domain LIKE '%.google.com')
the query for 1'605'923 tuples has a lag of 490ms, but this is bad for all the request to squid proxy.
My question is how optimize PostgreSQL to make that query more fast, or I need to use a NoSQL Database (I test with MongoDB and make the query in 609ms with less data).
I tried with FullText search, but this has english tokenize and the data are URLs (www.google.com/query?data1=3), Domains (bing.com) and Regex (.*.cu).