<?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: Feature size increasing after truncate and append in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1690299#M11877</link>
    <description>&lt;P&gt;Ah that makes sense, I didn't catch that in the original code you shared. Moving the reenable sync step to after the append was almost certainly it. Glad you were able to figure it out.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Mar 2026 18:42:50 GMT</pubDate>
    <dc:creator>AaronKoelker</dc:creator>
    <dc:date>2026-03-12T18:42:50Z</dc:date>
    <item>
      <title>Feature size increasing after truncate and append</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1684185#M11851</link>
      <description>&lt;P&gt;Hi Everybody,&lt;/P&gt;&lt;P&gt;I've encountered some inexplicable result when I'm running daily/weekly python scripts to updated hosted feature layers in ArcGIS Online where the feature storage size seems to balloon in size after each truncate and append option.&amp;nbsp;The hosted feature layer started a few weeks ago at like 60mb of feature storage, but it's now 1.5gbs and I'm at a loss at what's happening.&lt;/P&gt;&lt;P&gt;The layer is sync and edit enabled.&lt;/P&gt;&lt;P&gt;Basically we have two methods of updating feature layers.&lt;/P&gt;&lt;P&gt;1. Is where we call&amp;nbsp;rest endpoint directly and perform arcpy delate rows and append. And it seems to work and the end user doesn't seem to notice any issues.&lt;/P&gt;&lt;DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;SPAN&gt;HFL URL = "[URL]"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;arcpy&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;DeleteRows_management&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;HFL URL&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;arcpy&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Append_management&lt;/SPAN&gt;&lt;SPAN&gt;(Local FC&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Source&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt; &lt;SPAN&gt;HFL URL&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"NO_TEST"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;2. The other method, we zip up a file geodatabase, upload it to AGO and perform a truncate and append (from the fgdb) to the feature layer.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Below are the steps after the zipped fgdb gets uploaded to AGO.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;SPAN&gt;flc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;manager&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;update_definition&lt;/SPAN&gt;&lt;SPAN&gt;({&lt;/SPAN&gt;&lt;SPAN&gt;"capabilities"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"Create,Delete,Query,Update,Editing,Sync"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"syncEnabled"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;False&lt;/SPAN&gt;&lt;SPAN&gt;})&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;featLyr&lt;/SPAN&gt;&lt;SPAN&gt;.manager.truncate()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;flc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;manager&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;update_definition&lt;/SPAN&gt;&lt;SPAN&gt;({&lt;/SPAN&gt;&lt;SPAN&gt;"capabilities"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"Create,Delete,Query,Update,Editing,Sync"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"syncEnabled"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;True&lt;/SPAN&gt;&lt;SPAN&gt;})&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;featLyr&lt;/SPAN&gt;&lt;SPAN&gt;.append(&lt;/SPAN&gt;&lt;SPAN&gt;item_id&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;fgd_item&lt;/SPAN&gt;&lt;SPAN&gt;.id,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;upload_format&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"filegdb"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;upsert&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;False&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;field_mappings&lt;/SPAN&gt;&lt;SPAN&gt;=[])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;We also have scripts that just&amp;nbsp;&lt;EM&gt;&lt;SPAN&gt;item&lt;/SPAN&gt;&lt;SPAN&gt;.publish(&lt;/SPAN&gt;&lt;SPAN&gt;overwrite&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;True&lt;/SPAN&gt;&lt;SPAN&gt;),&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN&gt;but it's a little more finicky I've found to use than the truncate and append, until now. But I've not noticed feature layers exploding in storage space.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I almost feel like there should be like there's an adds and deletes table that needs to be compressed or something in AGO.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone encountered this issue or have any insights?&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;</description>
      <pubDate>Thu, 12 Feb 2026 22:28:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1684185#M11851</guid>
      <dc:creator>twangtx</dc:creator>
      <dc:date>2026-02-12T22:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Feature size increasing after truncate and append</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1689001#M11871</link>
      <description>&lt;P&gt;I know you're disabling it mid-step, but can you test it with a duplicate feature layer that doesn't have sync enabled at all? Sounds like it is still storing previous versions or a history of previous edits somewhere, and if you're doing a full truncate/append that's a lot of "edits".&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I need to do full overwrites I either use the .update() method to replace the whole file, or use spatially enabled dataframes (SEDF) and .edit_features(adds='your SEDF'). Something like the examples below. Could try one of these as an alternative to append() .&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;### Update Hosted Feature Layers Examples
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

updated_data = r'this_is_a_path_to_file.csv' # path to your updated dataset, the file type must match whatever the service was published with
itemid = '' # the itemid for the hosted feature service you want to update in ArcGIS Online, you can get it off item page in AGO
portal_url = '' # "https://example.maps.arcgis.com"
user = '' # AGO username
pw = '' # AGO password


### Log in to ArcGIS Online account
gis = GIS(portal_url, user, pw)
un = gis.properties.user.username
print(f'\nLogged in as {un} on {portal_url} \n')


#############################################################################
### Example 1 (Overwrite directly from local file)
# If you published to AGO from a local file (csv, fgdb, etc.), this is the simplest way to overwrite
# The new data must have the same filename and file type, and FGDBs must be zipped
hostedfeature = gis.content.get(itemid)
flayer = FeatureLayerCollection.fromitem(hostedfeature)
flayer.manager.overwrite(updated_data)
print("Hosted feature layer updated with the latest and greatest")

# That is the barebones method, but you can update lots of other stuff too, for example the description, title, etc.
# https://developers.arcgis.com/rest/users-groups-and-items/common-parameters/
item_properties={
    "description":"Here is my description, isn't it great",
    "title":"Great Item Title"
    }
hostedfeature.update(item_properties)

# Or the thumbnail
thumb = r'path_to_some_picture.jpg' # can also use a image url
hostedfeature.update(thumbnail=thumb)

# Or you can disable and enable settings, like Sync
syncoff = {"capabilities": "Query, Extract"} 
hostedfeature.manager.update_definition(syncoff)

syncon = {"capabilities": "Query, Extract, Sync"}
hostedfeature.manager.update_definition(syncon)

# https://developers.arcgis.com/python/latest/samples/overwriting-feature-layers/#:~:text=updated_capitals_csv%27%2C%20csv_file_name))-,Overwrite%20the%20feature%20layer,-Let%20us%20overwrite


#############################################################################
### Example 2 (Go the edit route with a full truncate and append)
# You can do this either from a regular pandas dataframe if it's a table, a spatially enabled dataframe if there is geometry, or from a featureset
# If you are adding more than 1000 features you want to chunk it out
import pandas as pd
import os

hostedfeature = gis.content.get(itemid).layers[0] # if you have a hosted table you can use .tables[0] instead
hostedfeature.manager.truncate()

local_featureclass = os.path.join(r"path to a file geodatabase .gdb", "MyFeatureClass")
sedf = pd.DataFrame.spatial.from_featureclass(local_featureclass)

n = 1000
for i in range(0, len(sedf), n):
    chunk = sedf[i:i+n]
    result = hostedfeature.edit_features(adds=chunk)
    print(f'added items {i+1}-{i+n}...')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2026 16:50:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1689001#M11871</guid>
      <dc:creator>AaronKoelker</dc:creator>
      <dc:date>2026-03-06T16:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Feature size increasing after truncate and append</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1690006#M11876</link>
      <description>&lt;P&gt;Hi Aaron,&lt;/P&gt;&lt;P&gt;Thank you for responding.&lt;/P&gt;&lt;P&gt;I think we've got the issue "resolved" in that we kind of just went with the nuclear option. We ended up just overwriting the hosted feature layer from Pro with a feature class of the same schema. And the method that has been working for us so far is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Zip up a file geodatabase&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Upload to AGO&lt;/LI&gt;&lt;LI&gt;Disable sync&lt;/LI&gt;&lt;LI&gt;Truncate&lt;/LI&gt;&lt;LI&gt;Append from file geodatabase&lt;/LI&gt;&lt;LI&gt;Reenable sync&lt;/LI&gt;&lt;LI&gt;Delete the file geodatabase in AGO.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I think maybe the critical thing we did was append before reenabling the sync.&lt;/P&gt;&lt;P&gt;It's been running daily for a few weeks, and the feature storage size has been staying consistent.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2026 15:49:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1690006#M11876</guid>
      <dc:creator>twangtx</dc:creator>
      <dc:date>2026-03-11T15:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Feature size increasing after truncate and append</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1690299#M11877</link>
      <description>&lt;P&gt;Ah that makes sense, I didn't catch that in the original code you shared. Moving the reenable sync step to after the append was almost certainly it. Glad you were able to figure it out.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 18:42:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/feature-size-increasing-after-truncate-and-append/m-p/1690299#M11877</guid>
      <dc:creator>AaronKoelker</dc:creator>
      <dc:date>2026-03-12T18:42:50Z</dc:date>
    </item>
  </channel>
</rss>

