Qusetion re regexexp_split_to_array and last occurence

Mike Martin <[email protected]> Tue, 8 Oct 2019 16:48:40 +0100
Newsgroups gmane.comp.db.postgresql.sql
Message-ID <CAOwYNKb7mRHZvxoahPKRd2m2ZpSEr3B=+-XgoYZZK5ZZJgypfg@mail.gmail.com>
--000000000000596ea10594681ce5
Content-Type: text/plain; charset="UTF-8"

Hi
I have the following in a trigger (update/insert)
 NEW.filearr := (regexp_split_to_array(NEW.tagfile,'(?:/|\.)'))[2:];

This works except when there is a period in the filename

So I did this instead

arrfile=(regexp_split_to_array(NEW.tagfile,'/'))[2:];
NEW.filearr
:=arrfile[1:cardinality(arrfile)-1]||regexp_matches(arrfile[cardinality(arrfile)],'(.*)\.(.*)');

Which works perfectly, except performance is 50% slower on a dataset of
around 20k

Is there a better solution

Mike

--000000000000596ea10594681ce5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi</div><div>I have the following in a trigger (updat=
e/insert)<br></div><div>=C2=A0NEW.filearr :=3D (regexp_split_to_array(NEW.t=
agfile,&#39;(?:/|\.)&#39;))[2:];</div><div><br></div><div>This works except=
 when there is a period in the filename</div><div><br></div><div>So I did t=
his instead<br></div><div><br></div><div>arrfile=3D(regexp_split_to_array(N=
EW.tagfile,&#39;/&#39;))[2:];<br>			NEW.filearr :=3Darrfile[1:cardinality(a=
rrfile)-1]||regexp_matches(arrfile[cardinality(arrfile)],&#39;(.*)\.(.*)&#3=
9;);<br></div><div><br></div><div>Which works perfectly, except performance=
 is 50% slower on a dataset of around 20k</div><div><br></div><div>Is there=
 a better solution</div><div><br></div><div>Mike<br></div></div>

--000000000000596ea10594681ce5--