<?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 Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW .... in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1334431#M54859</link>
    <description>&lt;P&gt;Apologies, it was a copy and paste job from one of my workflows and forgot to replace. Code has been updated to reflect.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Oct 2023 07:02:18 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2023-10-03T07:02:18Z</dc:date>
    <item>
      <title>Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1283028#M51742</link>
      <description>&lt;UL&gt;&lt;LI&gt;I have a hosted feature layer (706 features) and i want to update some rows based on an external table&lt;/LI&gt;&lt;LI&gt;I have a file geodatabase table on my C: drive&lt;/LI&gt;&lt;LI&gt;I have both the hosted feature layer and the table in an ArcPro session&lt;/LI&gt;&lt;LI&gt;I joined the table to the hosted feature layer in Pro and am trying to calculate a bunch of fields&lt;/LI&gt;&lt;LI&gt;EXTREMELY SLOW (10 minutes for each field)&lt;/LI&gt;&lt;LI&gt;I've tried using Arcade and Python as my Expression Types and they are both extremely slow&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is going on?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 20:02:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1283028#M51742</guid>
      <dc:creator>GISUser74305830</dc:creator>
      <dc:date>2023-04-26T20:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1283237#M51751</link>
      <description>&lt;P&gt;It is a slow process using the Calculate Field tool in ArcGIS Pro with a hosted feature service.&lt;/P&gt;&lt;P&gt;This can rapidly be sped up using a combination of ArcPy and ArcGIS for Python API.&lt;/P&gt;&lt;P&gt;Use ArcPy to create a dictionary of your gdb data with the join key field as the key in the dictionary and the other attributes as a list for the dictionary value.&lt;/P&gt;&lt;P&gt;Use ArcGIS for Python API to update your feature service data. Workflow could look similar to below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS
import arcpy

fc = r"path\to\gdb\fc"

## connect to AGOL
agol = GIS("home")

# feature service item from AGOL
item = agol.content.get("FS_ITEM_ID")

# get the layer object by layer name in the feature servic
lyr = [lyr for lyr in item.layers if lyr.properties.name == "NAME_OF_LAYER_TO_UPDATE"][0]

# create join dictionary to be used below
join_dict = {}

with arcpy.da.SearchCursor(fc, ["KEYFIELDNAME1", "FIELDNAME2", "FIELDNAME3", "FIELDNAME4", "FIELDNAME5"]) as cursor:
    for row in cursor:
        join_dict[row[0]] = [row[1], row[2], row[3], row[4]]

# querying the layer to return a feature set object
query = lyr.query()

# populating field edits for layer update and field calculations
edit = [f for f in query.features]
for f in edit:
    join_key = f.attributes["KEYFIELDNAME1"]

    if join_key in join_dict:
        f.attributes["FIELDNAME2"] = join_dict[join_key][0]
        f.attributes["FIELDNAME3"] = join_dict[join_key][1]
        f.attributes["FIELDNAME4"] = join_dict[join_key][2]
        f.attributes["FIELDNAME5"] = join_dict[join_key][3]

# applying field calculation updates to the layer
print(lyr.edit_features(updates=edit))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 07:01:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1283237#M51751</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-10-03T07:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1283274#M51753</link>
      <description>&lt;P&gt;Use SQL in the calculate field tool. Calculating 10,000-30,000 records will go from 2 hours (arcade) to a matter of minutes (SQL). It's highlighted in the documentation:&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/arcgis-online/manage-data/calculate-fields.htm" target="_blank" rel="noopener"&gt;https://doc.arcgis.com/en/arcgis-online/manage-data/calculate-fields.htm&lt;/A&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://doc.arcgis.com/en/arcgis-online/manage-data/calculate-fields.htm#ESRI_SECTION1_28F344E2E80C410A98D443FF301DF989" target="_blank" rel="noopener"&gt;SQL&lt;/A&gt;—Use SQL for the fastest performance with calculations that can be performed with standardized SQL (SQL-92) expressions on nonspatial attributes. You can run SQL on sync-enabled hosted feature layers and layers configured to track feature creators and editors, whereas you cannot run&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Arcade&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;expressions on such layers.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I believe it'll be faster if the 'undo' option is disabled, so the edits are committed immediately. I don't have a reference to back this up.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 12:23:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1283274#M51753</guid>
      <dc:creator>ChristopherCounsell</dc:creator>
      <dc:date>2023-04-27T12:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1283315#M51758</link>
      <description>&lt;P&gt;Far superior! Forgot about that one. It will reduce updating 10000 records in a hosted feature service from hours to seconds. One of the versions of ArcGIS Pro (in the 2.6 series) kept crashing on us when using SQL in the Calculate Field tool and we used the code in my previous post to overcome at the time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 13:26:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1283315#M51758</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-04-27T13:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1284048#M51798</link>
      <description>&lt;P&gt;I have a join, so my only options are Python and Arcade.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Calculation options" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69505iCB5ADDB65612527C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Calc options.png" alt="Calculation options" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Calculation options&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 19:02:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1284048#M51798</guid>
      <dc:creator>GISUser74305830</dc:creator>
      <dc:date>2023-04-28T19:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1284609#M51842</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/421586"&gt;@GISUser74305830&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Python script is a great alternative so. It will be a lot faster than the CalculateField tool when using a Feature Service in ArcGIS Pro.&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 08:04:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1284609#M51842</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-05-02T08:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1327092#M54480</link>
      <description>&lt;P&gt;I finally dug into this and applied it and it worked perfectly! Thank you very much!&lt;/P&gt;</description>
      <pubDate>Sun, 10 Sep 2023 02:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1327092#M54480</guid>
      <dc:creator>GISUser74305830</dc:creator>
      <dc:date>2023-09-10T02:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1334281#M54845</link>
      <description>&lt;P&gt;What is duct_dict here? Should I create an empty dictionary with that name?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 20:10:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1334281#M54845</guid>
      <dc:creator>Kev</dc:creator>
      <dc:date>2023-10-02T20:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating fields in hosted feature layers VERY SLOOOOWWWWW ....</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1334431#M54859</link>
      <description>&lt;P&gt;Apologies, it was a copy and paste job from one of my workflows and forgot to replace. Code has been updated to reflect.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 07:02:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculating-fields-in-hosted-feature-layers-very/m-p/1334431#M54859</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-10-03T07:02:18Z</dc:date>
    </item>
  </channel>
</rss>

