Re: How to get around LIKE inefficiencies? - Mailing list pgsql-hackers

From Philip Warner
Subject Re: How to get around LIKE inefficiencies?
Date
Msg-id 3.0.5.32.20001106135128.0247bd30@mail.rhyme.com.au
Whole thread Raw
In response to Re: How to get around LIKE inefficiencies?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: How to get around LIKE inefficiencies?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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   |/


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to get around LIKE inefficiencies?
Next
From: Philip Warner
Date:
Subject: Re: How to get around LIKE inefficiencies?