Question re regexexp_split_to_array and last oc
Mike Martin <[email protected]> Tue, 8 Oct 2019 16:51:01 +0100
| Newsgroups | gmane.comp.db.postgresql.sql |
|---|---|
| Message-ID | <CAOwYNKaJDthPrxYtt7e9Nkm6=n-3Tff=VRzEPsObqWWox5k+hA@mail.gmail.com> |
--000000000000c03f0b0594682459 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 --000000000000c03f0b0594682459 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,'(?:/|\.)'))[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,'/'))[2:];<br> NEW.filearr :=3Darrfile[1:cardinality(a= rrfile)-1]||regexp_matches(arrfile[cardinality(arrfile)],'(.*)\.(.*)= 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 class=3D"gmail-yj6qo gmail-ajU"><div id=3D"gma= il-:3ie" class=3D"gmail-ajR" tabindex=3D"0"><img class=3D"gmail-ajT" src=3D= "https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif"></div></div>= <span class=3D"gmail-HOEnZb gmail-adL"><font color=3D"#888888"><div><br></d= iv><div>Mike</div></font></span></div> --000000000000c03f0b0594682459--