<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How can I improve performance of this Arcade data expression that joins tables? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1353168#M6835</link>
    <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;In the simpler case of joining one related table, the base of the script I got was from this &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/JoinLayerFieldsToTable.md" target="_self"&gt;github page&lt;/A&gt; (and pasted below). The only minor change I made was to specify fields for the feature sets as opposed to returning all fields.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated! Thanks all.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Nov 2023 15:15:33 GMT</pubDate>
    <dc:creator>Vinzafy</dc:creator>
    <dc:date>2023-11-24T15:15:33Z</dc:date>
    <item>
      <title>How can I improve performance of this Arcade data expression that joins tables?</title>
      <link>https://community.esri.com/t5/developers-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1353168#M6835</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;In the simpler case of joining one related table, the base of the script I got was from this &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/JoinLayerFieldsToTable.md" target="_self"&gt;github page&lt;/A&gt; (and pasted below). The only minor change I made was to specify fields for the feature sets as opposed to returning all fields.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated! Thanks all.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2023 15:15:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1353168#M6835</guid>
      <dc:creator>Vinzafy</dc:creator>
      <dc:date>2023-11-24T15:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I improve performance of this Arcade data expression that joins tables?</title>
      <link>https://community.esri.com/t5/developers-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1353316#M6836</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-dashboards-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1353315/highlight/true#M8768" target="_blank" rel="noopener"&gt;Link to my answer in the Dashboard Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Nov 2023 11:24:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1353316#M6836</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-11-26T11:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I improve performance of this Arcade data expression that joins tables?</title>
      <link>https://community.esri.com/t5/developers-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1354063#M6837</link>
      <description>&lt;P data-unlink="true"&gt;For anyone facing similar issues, this is the way! The method outlined by &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt; in the &lt;A href="https://community.esri.com/t5/arcgis-dashboards-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1353315/highlight/true#M8768" target="_self"&gt;Dashboard Community&lt;/A&gt; made load times for a data expression 47 times faster than the previous method. Awesome!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 14:56:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-can-i-improve-performance-of-this-arcade-data/m-p/1354063#M6837</guid>
      <dc:creator>Vinzafy</dc:creator>
      <dc:date>2023-11-28T14:56:43Z</dc:date>
    </item>
  </channel>
</rss>

