Regular expressions and indexes

From: Hans-Jürgen Schönig <hs(at)cybertec(dot)at>
To: pgsql-sql(at)postgresql(dot)org
Subject: Regular expressions and indexes
Date: 2001-04-27 09:04:25
Message-ID: 3AE93619.BE51C143@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Is there any possibility to make PostgreSQL use indexes when working
with regular expressions?

performance=# EXPLAIN SELECT * FROM perftest WHERE id=100;
NOTICE: QUERY PLAN:

Index Scan using idx_id_perftest on perftest (cost=0.00..4.98 rows=1
width=20)

EXPLAIN

performance=# EXPLAIN SELECT * FROM perftest WHERE id ~ '^100$';
NOTICE: QUERY PLAN:

Seq Scan on perftest (cost=100000000.00..100218966.00 rows=100000
width=20)

EXPLAIN

It is clear that complex regular expressions can possibly never use an
index but is it possible to use it when looking for the beginning of a
string (e.g.: ^100).

Hans

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2001-04-27 15:08:39 Re: Using Transaction Blocks w/ SELECT
Previous Message Doug McNaught 2001-04-26 23:54:21 Re: JDBC speed question.