Re: Is it possible to search for sub-strings...

From: Vince Vielhaber <vev(at)michvhf(dot)com>
To: Steve Heaven <steve(at)thornet(dot)co(dot)uk>
Cc: Mitch Vincent <mitch(at)venux(dot)net>, John Draper <crunch(at)webcrunchers(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Is it possible to search for sub-strings...
Date: 2000-09-19 16:49:45
Message-ID: Pine.BSF.4.21.0009191245590.47246-100000@paprika.michvhf.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 19 Sep 2000, Steve Heaven wrote:

> At 09:00 19/09/00 -0700, Mitch Vincent wrote:
> >LIKE can use indexes, ~* can not, that's LIKE's main advantage (at least in
> >my opinion).
> >
>
> ~ does use indexes, ~* doesnt,
> but then nor does the equivalent upper(columnname) LIKE 'TERM'. Make sure
> you're comparing apples with apples.

It can:

campsites=> explain select * from camps4 where upper(city) like 'MACKINA%';
NOTICE: QUERY PLAN:

Index Scan using camps4_ucity on camps4 (cost=106.34 size=644 width=132)

In my particular case the like search needed to perform an upper() like
select, an index was created for this purpose (in this case: camps4_ucity)

Vince.

>
>
> explain select * from all_title_fti where string like 'A%';
> NOTICE: QUERY PLAN:
>
> Index Scan using all_title_idx on all_title_fti (cost=86633.57 rows=1
> width=16)
>
> explain select * from all_title_fti where string ~ '^A';
> NOTICE: QUERY PLAN:
>
> Index Scan using all_title_idx on all_title_fti (cost=86633.57 rows=1
> width=16
>
> explain select * from all_title_fti where upper(string) like 'A%';
> NOTICE: QUERY PLAN:
>
> Seq Scan on all_title_fti (cost=170921.58 rows=1083414 width=16)
>

--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev(at)michvhf(dot)com http://www.pop4.net
128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ross J. Reedstrom 2000-09-19 16:53:29 Re: nasty problem with redhat 6.2 + pg 7.02
Previous Message Lamar Owen 2000-09-19 16:36:22 Re: nasty problem with redhat 6.2 + pg 7.02