Mapping new column based on the value of another column


I have a dashboard that is monitoring a number of systems and I have a table with a hostname column along with other columns of info. Right now I have about 27 systems in the list and although the hostname naming convention does indicate the location of the system, the non IT folks don’t know how to translate it. In InfluxDBv2 I am using the map() function to translate based on whether a certain string is found in the hostname, if so add a specific location to a new column.

|>map(fn: (r) =>
({r with location: if strings.containsStr(v: r[“hostname”], substr: “site1”) then “LocationA” else “no location”}))

This works without issue, except with 27 of these defined my 10 min time range query goes from 1 second to ~18-20 seconds to complete.

Is there a more efficient way to do this to not extend the query time by so much?