Hey all,
Posting this here to see if anyone can help improve the performance of an Arcade script I'm using. The script is essentially a join between a spatial layer and a related table and is used as a data expression in a dashboard.
Though this is currently achieved via a joined view layer, that restricts schema edits to the hosted feature layer and I'm hoping to get away from that. Additionally, another use case I have joins three related tables which you can't do with a joined view layer.
In the simpler case of joining one related table, the base of the script I got was from this github page (and pasted below). The only minor change I made was to specify fields for the feature sets as opposed to returning all fields.
If I use that data expression as a source for a dashboard item (e.g,. an indicator), load times are around 75 seconds vs. 3-5 seconds though a joined view layer.
Is there anyway to improve performance of this script? It would help immensely. My other use case where I join three related tables currently takes around 2.5 minutes to load. Though it works as expected, the load times are brutal.
Any help is greatly appreciated! Thanks all.
var portal = Portal("https://www.arcgis.com/");
var polyfs = FeatureSetByPortalItem(
    portal,
    "4dbbad3d6f694e0ebc7c3b4132ea34df",
    0,
    ["*"],
    false
);
var tablefs = FeatureSetByPortalItem(
    portal,
    "4dbbad3d6f694e0ebc7c3b4132ea34df",
    6,
    ["*"],
    false
);
// Create empty features array and feat object
var features = [];
var feat;
// Populate Feature Array
for (var t in tablefs) {
    var tableID = t["FeatureID"]
    for (var p in Filter(polyfs, "HydroID = "+tableID)){
        feat = {
            attributes: {
                FeatureID: tableID,
                Name: p["DPS_Region"],
				ModelID: t["ModelID"],
                AddressCount: t["AddressCount"],
                MAX_TSTime: t["MAX_TSTime"],
            }
        }
    Push(features, feat)
    }
}
var joinedDict = {
    fields: [
        { name: "FeatureID", type: "esriFieldTypeString" },
        { name: "Name", type: "esriFieldTypeString" },	
        { name: "ModelID", type: "esriFieldTypeInteger" },
        { name: "AddressCount", type: "esriFieldTypeInteger" },
        { name: "MAX_TSTime", type: "esriFieldTypeString" },
    ],
    'geometryType': '',
    'features':features
};
// Return dictionary cast as a feature set 
return FeatureSet(joinedDict);
Solved! Go to Solution.
Link to my answer in the Dashboard Community
Link to my answer in the Dashboard Community
For anyone facing similar issues, this is the way! The method outlined by @JohannesLindner in the Dashboard Community made load times for a data expression 47 times faster than the previous method. Awesome!
