Re: Qusetion re regexexp_split_to_array and last occurence
От | David G. Johnston |
---|---|
Тема | Re: Qusetion re regexexp_split_to_array and last occurence |
Дата | |
Msg-id | CAKFQuwYXpzF=JKGhdXUBcSYf7NqXTMKsnbOB3XkVFg9D8=7tSw@mail.gmail.com обсуждение исходный текст |
Ответ на | Qusetion re regexexp_split_to_array and last occurence (Mike Martin <mike@redtux.plus.com>) |
Список | pgsql-sql |
On Tue, Oct 8, 2019 at 10:31 AM Mike Martin <mike@redtux.plus.com> wrote:
arrfile=(regexp_split_to_array(NEW.tagfile,'/'))[2:];
string_to_array()? You aren't providing a regexp so it seems wasteful to use the regexp engine to perform the task.
NEW.filearr :=arrfile[1:cardinality(arrfile)-1]||regexp_matches(arrfile[cardinality(arrfile)],'(.*)\.(.*)');
regexp_match()? You aren't returning a set of matches so use the scalar function. Probably still need to deal with null properly.
Which works perfectly, except performance is 50% slower on a dataset of around 20kIs there a better solution
Probably not materially - it seems like you have to do it in two parts - one to break apart the paths and then one to handle the fact that you want the part subsequent to the final period (i.e., the file extension) in its own array cell. Choosing the best function for each job will hopefully improve matters at least a bit.
David J.
В списке pgsql-sql по дате отправления: