You may very likely be correct. Currently this function uses a regular expression to determine the line item fields, and when used with the select statement this is going to happen over and over again for every record. So I think it might be significantly faster to hand code like this:
select (PartNumber1+";"+PartNumber2+";"+ ... +";"+PartNumber9) contains lvPart
Of course the last number is going to vary depending on how many line item fields you actually have in your database.
Or, here’s a version that will automatically build the formula needed for any number of line item fields, then uses the execute statement to run the selection. This should be just as fast as the hand coded solution above.
let xfields = replace(arraystrip(arrayfilter(dbinfo("lineitemfields",""),cr(),{?(import() regexmatch "^PartNumber[0-9]+$",import(),"")}),cr()),cr(),{+";"+})
execute "select ("+xfields+") contains "+quoted(lvPart)
I would be interested in how much faster this works for you.
Longer term, I’ve made a note to look into this. The solution’s I’ve given above are going to be as fast as it can possibly be, I think, but it would be nice if a simple solution using lineitemarray( would have better performance.