Skip site navigation (1) Skip section navigation (2)

Re: t1.col like '%t2.col%'

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Dan Kaplan <dkaplan(at)citizenhawk(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: t1.col like '%t2.col%'
Date: 2008-02-28 05:47:22
Message-ID: Pine.LNX.4.64.0802280833040.31180@sn.sai.msu.ru (view raw or flat)
Thread:
Lists: pgsql-performance
On Wed, 27 Feb 2008, Dan Kaplan wrote:

> I've got a lot of rows in one table and a lot of rows in another table.  I
> want to do a bunch of queries on their join column.  One of these is like
> this: t1.col like '%t2.col%'

We have an idea how to speedup wildcard search at the expense of the size - 
we have to index all permutation of the original word. Then we could
use GIN for quieries like a*b.

>
>
>
> I know that always sucks.  I'm wondering how I can make it better.  First, I
> should let you know that I can likely hold both of these tables entirely in
> ram.  Since that's the case, would it be better to accomplish this with my
> programming language?  Also you should know that in most cases, t1.col and
> t2.col is 2 words or less.  I'm not sure if that matters, I mention it
> because it may make tsearch2 perform badly.
>

contrib/pg_trgm should help you.

>

 	Regards,
 		Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83

In response to

Responses

pgsql-performance by date

Next:From: Robins TharakanDate: 2008-02-28 14:31:19
Subject: Bypassing useless ORDER BY in a VIEW
Previous:From: Joel StevensonDate: 2008-02-28 02:19:12
Subject: Re: LISTEN / NOTIFY performance in 8.3

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group