SQL optimization - WHERE SomeField STARTING WITH ...

From: Bill <pg(at)dbginc(dot)com>
To: PgSQL General <pgsql-general(at)postgresql(dot)org>
Subject: SQL optimization - WHERE SomeField STARTING WITH ...
Date: 2008-08-28 18:10:47
Message-ID: 48B6EA27.30503@dbginc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Bill

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-08-28 18:23:10 Re: temp schemas
Previous Message Tom Lane 2008-08-28 18:08:18 Re: strange explain analyze output