Re: SQL optimization - WHERE SomeField STARTING WITH ...

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Bill <pg(at)dbginc(dot)com>
Cc: PgSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL optimization - WHERE SomeField STARTING WITH ...
Date: 2008-08-28 19:27:32
Message-ID: 48B6FC24.4070808@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Bill,

Bill wrote:
> The SQL database servers I have worked with cannot use and index for a
> SELECT of the form
>
> SELECT * FROM ATABLE
> WHERE AFIELD LIKE ?
>
> because there is no way to know the location of the wild card until the
> parameter value is known. InterBase and Firebird allow
>
> SELECT * FROM ATABLE
> WHERE AFIELD STARTING WITH ?
>
> which is equivalent to LIKE 'ABC%' and will use an index on AFIELD. Is
> there a similar syntax in PostgreSQL?

Yes, its actually: LIKE 'ABC%' and it will use an index.

Regards
Tino

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John T. Dow 2008-08-28 19:35:17 Re: WAL file questions - how to relocate on Windows, how to replay after total loss, etc
Previous Message Dave Page 2008-08-28 19:11:45 Re: temp schemas