Impact of contains() on performance

I think there is something wrong with the function contains().
Query 1 does not use contains() and takes 0.15s.

    from(bucket: "short")
    |> range(start: v.timeRangeStart,stop: v.timeRangeStop)
    |> filter(fn: (r)=> r["_measurement"] == "Phasor")
    |> filter(fn: (r) => r["UID"] =~ /RepDev0002/)  
    |> filter(fn: (r)=> r._field == "mag")
    |> aggregateWindow(every: 20ms, fn: mean, createEmpty: true, timeSrc: "_start")
    |> group()

Query 2, provides identical output but takes 4.2s . I just replaced the filter with regex with contains()

MeasUID = ["RepDev0002-IA1","RepDev0002-IB1","RepDev0002-IC1","RepDev0002-IA2","RepDev0002-IB2","RepDev0002-IC2","RepDev0002-VA1","RepDev0002-VB1","RepDev0002-VC1"]
from(bucket: "short")
|> range(start: v.timeRangeStart,stop: v.timeRangeStop)
|> filter(fn: (r)=> r["_measurement"] == "Phasor")
|> filter(fn: (r)=> contains(value: r.UID,set: MeasUID))
|> filter(fn: (r)=> r._field == "mag")
|> aggregateWindow(every: 20ms, fn: mean, createEmpty: true, timeSrc: "_start")
|> group()

Obviously the contains() has the advantage of allowing the user to have an array coming from another query or a template variable, so it is more flexible. But I am wondering if a 30x execution time is justifiable.
Maybe I am using it wrongly or there is another way to make a dynamic filtering (without using regex as in query 1)?
Thanks!

Hello @MzazM,
Welcome! Thank you for sharing your question and your patience. I don’t know the answer. I’m passing this along to the Flux team. Interested to see what they say.