Re: SQL optimization - WHERE SomeField STARTING WITH ... - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: SQL optimization - WHERE SomeField STARTING WITH ...
Date
Msg-id 48BBF145.1060107@gmx.net
Whole thread Raw
In response to SQL optimization - WHERE SomeField STARTING WITH ...  (Bill <pg@dbginc.com>)
List pgsql-general
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?

One workaround might be to rewrite the query using some string function
(substring, position, or write your own) and index over that function.


pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: indexes on functions and create or replace function
Next
From: Peter Eisentraut
Date:
Subject: Re: determining existence of database and language