non-equi self-join optimization

From: "George Pavlov" <gpavlov(at)mynewplace(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: non-equi self-join optimization
Date: 2006-01-17 20:57:30
Message-ID: CCB89282FCE1024EA3DCE687A96A51640445D978@ehost010-6.exch010.intermedia.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a table of names with two subsets of entities. I want to find
those names from set 1 that are substrings of names from set 2 from the
same table. Basically the pared down query I want is something like
this:

select t1.myname, t2.myname
from mytable t1
inner join mytable t2
on position (t1.myname in t2.myname) > 0
where t1.flag = 1
and t2.flag = 2
;

I have gone through a few variations on the theme, but none perform too
well. Any advice on the best way to optimize a query like this would be
appreciated.

Thanks!

George

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Christian Paul B. Cosinas 2006-01-17 22:21:25 Characters that needs escape characters when inserting to database
Previous Message Michael Fuhr 2006-01-17 17:56:42 Re: Characters that needs escape characters when inserting to database