pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Dutcher <dave@tridecap.com>
To: 'Alexandru Coseru' <alexandru.coseru@totaltelecom.ro>
To: pgsql-performance@postgresql.org
Subject: Re: Regex performance issue
Date: Sat, 2 Dec 2006 14:36:49 -0600
Message-ID: <030b01c71651$984577c0$8300a8c0@tridecap.com> (raw)
In-Reply-To: <00d901c71644$326b0490$3cb16956@alex>

> -----Original Message-----
> From: pgsql-performance-owner@postgresql.org On Behalf Of Alexandru Coseru
> asterisk=> explain analyze SELECT * FROM destlist WHERE 
> '0039051248787' ~ 
> prefix AND id_ent='-2' AND dir=0 ORDER by length(prefix) DESC;
>
>                                                              
> QUERY PLAN
> --------------------------------------------------------------
> ----------------------------------------------------------------------
>  Sort  (cost=7925.07..7925.15 rows=31 width=67) (actual 
> time=857.715..857.716 rows=2 loops=1)
>    Sort Key: length((prefix)::text)
>    ->  Bitmap Heap Scan on destlist  (cost=60.16..7924.30 
> rows=31 width=67) 
> (actual time=2.156..857.686 rows=2 loops=1)
>          Recheck Cond: ((id_ent = -2) AND (dir = 0))
>          Filter: ('0039051248787'::text ~ (prefix)::text)
>          ->  Bitmap Index Scan on destlist_indx2  (cost=0.00..60.16 
> rows=6193 width=0) (actual time=1.961..1.961 rows=5205 loops=1)
>                Index Cond: ((id_ent = -2) AND (dir = 0))
>  Total runtime: 857.804 ms
> (8 rows)
> 
>
>     "mmumu" btree (prefix varchar_pattern_ops)
> 

I'm surpised Postgres isn't using the index on prefix seeing as the index
uses the varchar_pattern_ops operator class.  It could be that the index
isn't selective enough, or is Postgres not able to use an index with Posix
regular expressions?  The docs seem to say that it can, but I'd be curious
to see what happens if you use LIKE instead of ~. 

Dave
 




view thread (13+ messages)  latest in thread

Message-ID: <030b01c71651$984577c0$8300a8c0@tridecap.com>
Permalink:  ../030b01c71651$984577c0$8300a8c0@tridecap.com/
Also on:    postgresql.org/message-id/030b01c71651$984577c0$8300a8c0@tridecap.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dave@tridecap.com, alexandru.coseru@totaltelecom.ro
  Subject: Re: Regex performance issue
  In-Reply-To: <030b01c71651$984577c0$8300a8c0@tridecap.com>

* 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