Re: Regex query not using index

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Postgres User <postgres(dot)developer(at)gmail(dot)com>
Cc: Chris <dmagick(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Regex query not using index
Date: 2008-02-20 10:31:18
Message-ID: 47BC0176.8090305@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Postgres User wrote:
> im trying to allow the client to pass a varchar param into my
> function, and want to avoid any parsing of the parameter inside the
> function, or code to build a sql string.
>
> if the function can use this code, it will be compiled and optimized
> (unlike a dynamic sql stirng)
>
> select * from mytable where fielda ~ p_param

No, you should never let users specify raw regex. at best they can
hog down your server. Regex is a state engine and you can create
endless loops.

Maybe we can see the overall picture of your query?

Regards
Tino

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jorge Godoy 2008-02-20 11:21:21 Re:
Previous Message Dimitri Fontaine 2008-02-20 09:37:43 Re: longest prefix match