pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
best index for ~ ordering?
4+ messages / 3 participants
[nested] [flat]

* best index for ~ ordering?
@ 2007-03-06 21:34  Gerardo Herzig <gherzig@fmed.uba.ar>
  0 siblings, 1 reply; 4+ messages in thread

From: Gerardo Herzig @ 2007-03-06 21:34 UTC (permalink / raw)
  To: pgsql-sql

Hi all, i have a large table with one varchar field, and im triyng to 
get information about what index should i use in order to using that 
index (if this is possible) for ~ searching, and/or using LIKE searching.

Thanks!
Gerardo



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: best index for ~ ordering?
@ 2007-03-06 22:28  Andrew Sullivan <ajs@crankycanuck.ca>
  parent: Gerardo Herzig <gherzig@fmed.uba.ar>
  0 siblings, 1 reply; 4+ messages in thread

From: Andrew Sullivan @ 2007-03-06 22:28 UTC (permalink / raw)
  To: pgsql-sql

On Tue, Mar 06, 2007 at 06:34:23PM -0300, Gerardo Herzig wrote:
> Hi all, i have a large table with one varchar field, and im triyng to 
> get information about what index should i use in order to using that 
> index (if this is possible) for ~ searching, and/or using LIKE searching.

What sort of match are you doing?  If you're doing left-anchored
searches (LIKE 'blah%') then your standard btree is good.  If you're
doing unanchored searches (LIKE '%blah%' or similar) you're best doing
tsearch.  If it's right-anchored, you can do an index on the reverse
of the string.

A 

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
Unfortunately reformatting the Internet is a little more painful 
than reformatting your hard drive when it gets out of whack.
		--Scott Morris



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: best index for ~ ordering?
@ 2007-03-07 03:28  gherzig@fmed.uba.ar
  parent: Andrew Sullivan <ajs@crankycanuck.ca>
  0 siblings, 1 reply; 4+ messages in thread

From: gherzig@fmed.uba.ar @ 2007-03-07 03:28 UTC (permalink / raw)
  To: pgsql-sql

Well, im wondering if is possible using LIKE '%blah%', even better would be
upper/lower(string) like '%blah%',

Im not at work right now, i will try it latter and makes you know about
the results of using tsearch indexing.

Thanks a lot, man!
Gerardo
> On Tue, Mar 06, 2007 at 06:34:23PM -0300, Gerardo Herzig wrote:
>> Hi all, i have a large table with one varchar field, and im triyng to
>> get information about what index should i use in order to using that
>> index (if this is possible) for ~ searching, and/or using LIKE
>> searching.
>
> What sort of match are you doing?  If you're doing left-anchored
> searches (LIKE 'blah%') then your standard btree is good.  If you're
> doing unanchored searches (LIKE '%blah%' or similar) you're best doing
> tsearch.  If it's right-anchored, you can do an index on the reverse
> of the string.
>
> A
>
> --
> Andrew Sullivan  | ajs@crankycanuck.ca
> Unfortunately reformatting the Internet is a little more painful
> than reformatting your hard drive when it gets out of whack.
> 		--Scott Morris
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly
>
>


-- 
Gerardo Herzig
Direccion General de Organizacion y Sistemas
Facultad de Medicina
U.B.A.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: best index for ~ ordering?
@ 2007-03-07 18:32  Andrew Sullivan <ajs@crankycanuck.ca>
  parent: gherzig@fmed.uba.ar
  0 siblings, 0 replies; 4+ messages in thread

From: Andrew Sullivan @ 2007-03-07 18:32 UTC (permalink / raw)
  To: pgsql-sql

On Wed, Mar 07, 2007 at 12:28:57AM -0300, gherzig@fmed.uba.ar wrote:
> Well, im wondering if is possible using LIKE '%blah%', even better would be
> upper/lower(string) like '%blah%',

Your better bet then is either to index lower(string) or better, on
insert convert everything to lower().

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
The plural of anecdote is not data.
		--Roger Brinner



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2007-03-07 18:32 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-03-06 21:34 best index for ~ ordering? Gerardo Herzig <gherzig@fmed.uba.ar>
2007-03-06 22:28 ` Andrew Sullivan <ajs@crankycanuck.ca>
2007-03-07 03:28   ` gherzig@fmed.uba.ar
2007-03-07 18:32     ` Andrew Sullivan <ajs@crankycanuck.ca>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox