pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mitch Vincent <mitch@venux.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: LIKE and regex
Date: Thu, 18 May 2000 12:35:17 -0400
Message-ID: <24106.958667717@sss.pgh.pa.us> (raw)
In-Reply-To: <014b01bfc0e0$9fb352c0$4100000a@venux.net>
References: <014b01bfc0e0$9fb352c0$4100000a@venux.net>

"Mitch Vincent" <mitch@venux.net> writes:
> I'm wondering if LIKE uses regex internally.

No, it's just a pretty brain-dead scanner.  You can find the code in
backend/utils/adt/like.c if you care.

Perhaps it'd make sense to translate the LIKE pattern into an equivalent
regex and then use the regex code, but no one's done it.

> I'm trying to find the
> quickest / fastest way to search for any occurance of a given string in a
> stored field.
> query: select * from applicants where firstname LIKE '%mitch%';
> query: select * from applicants where firstname ~ lower('mitch');

I think the actual operator processing is going to be swamped by
tuple-fetching overhead, so there's not going to be much difference.
What you ought to be thinking about is how you could replace the
brute-force scan with an index lookup.  Possibly you could adapt the
ideas in contrib/fulltextindex.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <24106.958667717@sss.pgh.pa.us>
Permalink:  ../24106.958667717@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24106.958667717@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mitch@venux.net
  Subject: Re: LIKE and regex
  In-Reply-To: <24106.958667717@sss.pgh.pa.us>
  References: <014b01bfc0e0$9fb352c0$4100000a@venux.net> <24106.958667717@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox