Select to view content in your preferred language

Truncate and Append

228
5
07-23-2025 01:03 PM
ChaceCarpenter
Occasional Contributor

I am trying to update a layer in AGOL by truncating it in a python notebook and then appending the updated data using python's append function. I was able to truncate the AGOL layer in my python notebook, but the append takes too long or it just gets stuck. Note: There are about 200k records that need appended. Is there a better workflow for this task. I need it to be automated hence the python script

0 Kudos
5 Replies
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @ChaceCarpenter,

I would highly suggest checking out python cursors as to potentially help speed up some processes. Often times it is easier to only append the necessary data rather than bulk updates. In conjunction with the cursors you can also use SQL query statements to also help speed up the process as well.

0 Kudos
ChaceCarpenter
Occasional Contributor

Can I compare the geometry of the feature class in agol to the newer feature class and only update the features whos geometry has changed with this method?  I feel like comparing the 2 tables will require more computing power than just truncating and appending. Is this not true?

0 Kudos
vijaybadugu
Frequent Contributor

I used backed sql scripts to upsert and delete operations. it is much faster .

0 Kudos
ChaceCarpenter
Occasional Contributor

Are you using the sql within a arcpy function?

0 Kudos
vijaybadugu
Frequent Contributor

You are using service in agol, you could use sql query along with arcpy cursors to update/delete /insert. Append also uses upsert functionality. If you are using backend database like sqlserver, Postgre , you could use sql queries to update using some primary key field. Geometry field stored in the backend database as binary, you can’t compare that with another feature class using sql .

0 Kudos