<?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: Speedup/Alternative to ArcGIS table truncation operation in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346478#M69171</link>
    <description>&lt;P&gt;Thanks for your fast response&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/191789"&gt;@BlakeTerhune&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried Append as suggested and it consumed similar time to insert cursor.&lt;/P&gt;&lt;P&gt;As you pointed out, Truncate is faster in comparison to Delete Rows in my code, but it the one consuming the most time in my case.&lt;/P&gt;&lt;P&gt;I guess there is no other mechanism to speed up Truncate operation.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2023 01:25:49 GMT</pubDate>
    <dc:creator>hhharsha36</dc:creator>
    <dc:date>2023-11-07T01:25:49Z</dc:date>
    <item>
      <title>Speedup/Alternative to ArcGIS table truncation operation</title>
      <link>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346404#M69167</link>
      <description>&lt;P&gt;I have a table within my ArcGIS Pro application which I created using the below code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;table1 = arcpy.CreateTable_management(None, "TableName1")
table2 = arcpy.CreateTable_management(None, "TableName2")

arcpy.management.AddRelate("TableName1", "key1", "TableName2", "key2", "KeyRelation", "ONE_TO_MANY")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am performing insert operations into this table every time I run a Python ToolBox which is done using the below code.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def truncate_place_table():
    st1 = time.perf_counter()
    arcpy.TruncateTable_management("TableName1")
    arcpy.TruncateTable_management("TableName2")
    arcpy.AddMessage(f"Table Truncation time taken: {time.perf_counter() - st1}")
    return True

def insert_to_table():
    truncate_place_table()
    with arcpy.da.InsertCursor("TableName1", INSERT_FIELD_NAMES) as cursor:
        arcpy.AddMessage(f"insert_doc: {doc}")
        cursor.insertRow(doc)
    return True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that the table truncation takes more than a second to complete. If I do not include the table truncation operation, the `insertRow` command does not work.&lt;/P&gt;&lt;P&gt;Is there any way to speed up table truncation or alternative to flush and insert new records to table at a faster pace?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 21:50:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346404#M69167</guid>
      <dc:creator>hhharsha36</dc:creator>
      <dc:date>2023-11-06T21:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Speedup/Alternative to ArcGIS table truncation operation</title>
      <link>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346414#M69168</link>
      <description>&lt;P&gt;Truncate is the fastest way to remove all rows from a table. &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/delete-rows.htm" target="_self"&gt;Delete Rows&lt;/A&gt; is an alternative, but it is not faster than Truncate.&lt;/P&gt;&lt;P&gt;Maybe instead of using an insert cursor, see if &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/append.htm" target="_self"&gt;Append&lt;/A&gt; is any faster.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 22:01:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346414#M69168</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2023-11-06T22:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Speedup/Alternative to ArcGIS table truncation operation</title>
      <link>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346478#M69171</link>
      <description>&lt;P&gt;Thanks for your fast response&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/191789"&gt;@BlakeTerhune&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried Append as suggested and it consumed similar time to insert cursor.&lt;/P&gt;&lt;P&gt;As you pointed out, Truncate is faster in comparison to Delete Rows in my code, but it the one consuming the most time in my case.&lt;/P&gt;&lt;P&gt;I guess there is no other mechanism to speed up Truncate operation.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 01:25:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346478#M69171</guid>
      <dc:creator>hhharsha36</dc:creator>
      <dc:date>2023-11-07T01:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Speedup/Alternative to ArcGIS table truncation operation</title>
      <link>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346676#M69176</link>
      <description>&lt;P&gt;If this is running on an enterprise geodatabase (RDBMS), there might be some specific database tuning to help. I'm not a DBA though.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 14:15:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/speedup-alternative-to-arcgis-table-truncation/m-p/1346676#M69176</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2023-11-07T14:15:19Z</dc:date>
    </item>
  </channel>
</rss>

