Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: <hamann(dot)w(at)t-online(dot)de>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results
Date: 2012-12-22 23:15:56
Message-ID: 00a801cde09a$4c3b1be0$e4b153a0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> >> There's a much easier fix to this problem though, which is to invent
> >> a "reverse ~" operator that does POSIX comparison with the pattern on
> >> the left. The hardest part of doing that for yourself is choosing a
> >> name for the reverse operator --- it just goes like
> >>
> >> create function reverse_regexeq(text, text) returns bool as 'select
> >> $2 ~ $1' language sql strict immutable;
> >>
> >> create operator ~~~ (procedure = reverse_regexeq, leftarg = text,
> >> rightarg = text);
> >>
> >> and similarly for the case-insensitive version, and there you go:
> >> pattern ~~~ ANY (whatever) solves the problem.
> >>
>
> Hi Tom,
>
> while it might work to reverse the order in a regex, I have experienced
> severe slowdown when the pattern comes from table data
>
> Regards
> Wolfgang Hamann

You at least have to provide a query that you feel is "too slow". Since you
claim a "slowdown" you should also provide a query the better performing
query you are referring to. For all queries provided you also need to
provide comparable timing information.

It is also unclear whether you experience this slowdown when using the
"reverse" expression only or if it occurs in any situation where the
expression comes from a table column rather than a string constant.

If it is indeed related to the custom reverse query the fact that you are
going through an SQL wrapper to access a c-level function is inevitably
going to degrade performance.

In short you need to provide much more detail and clarity regarding what
exactly made you draw this conclusion so that others can repeat and verify
and then provide meaningful explanations or solutions.

If you have not done so please read the content at
http://wiki.postgresql.org/wiki/Slow_Query_Questions and
http://wiki.postgresql.org/wiki/Guide_to_reporting_problems

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Arnold 2012-12-23 02:34:37 Insert Assertion Failed in strcoll_l.c:112
Previous Message hamann.w 2012-12-22 22:41:28 Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results