Re: How to get around LIKE inefficiencies?

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, The Hermit Hacker <scrappy(at)hub(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to get around LIKE inefficiencies?
Date: 2000-11-06 02:51:28
Message-ID: 3.0.5.32.20001106135128.0247bd30@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 21:28 5/11/00 -0500, Tom Lane wrote:
>A brute-force answer would be to remove the url_url index ;-)
>dunno if that would slow down other queries, however.

Could you trick it into not using the index (AND using the other strategy?)
by using a calculation:

SELECT ndict.url_id,ndict.intag
FROM ndict,url
WHERE ndict.word_id=1971739852
AND url.rec_id=ndict.url_id
AND ( (url.url || ' ') LIKE 'http://www.postgresql.org/% ');

it's a bit nasty.

If you had 7.1, the following might work:

SELECT url_id,intag From
(Select ndict.url_id,ndict.intag,url
FROM ndict,url
WHERE ndict.word_id=1971739852
AND url.rec_id=ndict.url_id) as zzz
Where
zzz.url LIKE 'http://www.postgresql.org/%'

But I don't know how subselect-in-from handles this sort of query - it
might be 'clever' enough to fold it somehow.

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2000-11-06 02:52:59 Re: How to get around LIKE inefficiencies?
Previous Message Bruce Momjian 2000-11-06 02:49:07 Re: How to get around LIKE inefficiencies?