Re: Creating an index-type for LIKE '%value%'

From: "Larry Rosenman" <ler(at)lerctr(dot)org>
To: "'Oleg Bartunov'" <oleg(at)sai(dot)msu(dot)su>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Creating an index-type for LIKE '%value%'
Date: 2005-02-07 21:16:51
Message-ID: E1CyGG7-0002Ds-MO@lerami.lerctr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oleg Bartunov wrote:
> Read
> http://www.sai.msu.su/~megera/postgres/gist/pg_trgm/README.pg_trgm
>
> Oleg
> On Mon, 7 Feb 2005, Martijn van Oosterhout wrote:
Would you have a suggestion to index the following query:

SELECT domain,message,'1' as truth FROM blacklist
WHERE somedomain ~* '(?:.+\.|)' || domain || '\$')

The somedomain is actually a constant passed in from Exim (it's the sender's
righthand
Side of an E-Mail address).

I'm looking to see if the domain name is in my blacklist.

I may just be SOL, but I figured I'd ask.

The blacklist table is:
exim=# \d blacklist
Table "public.blacklist"
Column | Type | Modifiers
-------------+-----------------------------+--------------------------
insert_when | timestamp(0) with time zone | default now()
insert_who | text | default "current_user"()
domain | text |
message | text |
Indexes:
"blacklist_dom_idx" btree ("domain")

exim=#

And contains records like:

exim=# select * from blacklist limit 1;
insert_when | insert_who | domain | message
------------------------+------------+----------+---------------------------
------
2003-12-22 21:02:49-06 | ler | 008\.net | 127.0.0.1 MX, SPAMMER
(008.net)
(1 row)

exim=#

Thanks!

LER

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler(at)lerctr(dot)org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Berend Tober 2005-02-07 21:20:36 Sorting when "*" is the initial character
Previous Message Robert Treat 2005-02-07 20:30:08 Re: Is there a peer-to-peer server solution with PG?