From: tjk@tksoft.com <tjk@tksoft.com>
To: neko@kredit.sth.szif.hu
Cc: pgsql-sql@hub.org
Subject: Re: [SQL] select a part of a name
Date: Thu, 9 Dec 1999 00:57:00 -0800 (PST)
Message-ID: <199912090857.AAA20012@uno.tksoft.com> (raw)
In-Reply-To: <Pine.LNX.4.10.9912090312510.23988-100000@kredit.sth.szif.hu>
I am just an observer here, but in my understanding,
it is impossible to create an index for this type of case,
and take advantage of it, because the index would have to
be on the partial string "jon" inside the words "Tom Jones"
and "jonas."
I.e. you have to do a sequential scan of all records to find
your matches. Speed of the query, therefore, is only influenced
by the comparison speed. Is a regex search faster, or is
a LIKE search faster? My guess is that a regex search such as
~* 'jon' would be the fastest because it proceeds through the
string one character at a time, and doesn't need to convert the
text to lower case first, like a LIKE search will have to.
This depends on the regex implementation in postgres, of course.
In any case, the difference should be insignificant. I would
use the method you find more convenient.
Troy
>
> On Wed, 8 Dec 1999, Moray McConnachie wrote:
> >
> > > use: where name like '%names%'
> >
> > Except that the user specified he wanted to be able to find Tom Jones
> > and jonas from the search text jon, so you either need to use:
> >
> > where lower(name) like ('%' ¦¦ lower(searchtext) ¦¦ '%')
>
> > or something similar, which is slow unless you have an index on
> > lower(name), and even then.
> I think, this case always will be slow. Because the first '%'. I'm not
> sure about all of access methods, and comparsion operators. But this
> combination of them (btree/hash -- like) can't do indexed substr lookup.
> Is there any tricks, to do it?
>
> --
> nek;(
>
>
> ************
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tjk@tksoft.com, neko@kredit.sth.szif.hu, pgsql-sql@hub.org
Subject: Re: [SQL] select a part of a name
In-Reply-To: <199912090857.AAA20012@uno.tksoft.com>
References: <Pine.LNX.4.10.9912090312510.23988-100000@kredit.sth.szif.hu> <199912090857.AAA20012@uno.tksoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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