Re: Worthwhile optimisation of position()?

From: Thomas Hallgren <thomas(at)tada(dot)se>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Worthwhile optimisation of position()?
Date: 2006-03-24 06:32:41
Message-ID: 44239289.3010205@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Christopher Kings-Lynne wrote:
> Is it worth allowing this:
>
> select count(*) from users_users where position('ch' in username) = 0;
>
> To be able to use an index, like:
>
> select count(*) from users_users where username like 'ch%';
>
> At the moment the position() syntax will do a seqscan, but the like
> syntax will use an index.
>
You must compare position('ch' in username) to '%ch%' instead of 'ch%' in this respect.

The position function must look for 'ch' everywhere in the string so there's no way it can
use an index.

Regards,
Thomas Hallgren

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tim Allen 2006-03-24 06:38:13 Re: Worthwhile optimisation of position()?
Previous Message Sean Davis 2006-03-24 02:58:15 Re: Bytea and perl