Re: Lexicographic index ?

From: "Peter Gibbs" <peter(at)emkel(dot)co(dot)za>
To: <pgsql-general(at)postgresql(dot)org>, <arnaud(dot)mlist1(at)free(dot)fr>
Subject: Re: Lexicographic index ?
Date: 2002-05-16 12:57:40
Message-ID: 070701c1fcd9$4312e8a0$0b01010a@emkel.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

----- Original Message -----
From: <arnaud(dot)mlist1(at)free(dot)fr>
To: <pgsql-general(at)postgresql(dot)org>

> select * from twords where words||'%' like 'saxophones';
>
> works but uses a sequential scan on the table...

The only method I have been able to find that will use the index is to
provide both upper and lower limits on the key.

For example:

select * from twords
where words <= 'saxophones'
and words >= 's'
and position(words in 'saxophones') = 1;

This uses the index in my test, whereas it doesn't if you leave out the
second condition, even if you add an 'order by' clause.
Using position is slightly faster on my system than using likes (but I am
only using the standard /usr/dict/words for testing, so I only have 45402
rows.

--
Peter Gibbs
EmKel Systems

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Gribble 2002-05-16 13:14:55 Iterating over rowtype/record fields?
Previous Message Doug McNaught 2002-05-16 12:49:02 Re: [INTERFACES] C & C ++Program Problem