Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group