<?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: da.InsertCursor super slow in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594745#M73899</link>
    <description>&lt;P&gt;Never mind, I read that wrong. I see what you're talking about. Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 12 Mar 2025 15:00:30 GMT</pubDate>
    <dc:creator>RandyBonds_Jr_</dc:creator>
    <dc:date>2025-03-12T15:00:30Z</dc:date>
    <item>
      <title>da.InsertCursor super slow</title>
      <link>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594569#M73894</link>
      <description>&lt;P&gt;I have the following code that will take around 12 Hours in insert 7,000 rows. I have no idea why it is so slow.&amp;nbsp;&lt;/P&gt;&lt;P&gt;the routeRunRows is just a dictionary from an oracle database (cursor.fetchAll() using the oracledb library). When I run the loop without the arcpy.da.InsertCursor it take seconds (which makes sense). Any help would be appreciated.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for row in routeRunRows:
    if (x%1000) == 0:
        message = str(x) + ' Processed...'; show_py_message()
    x += 1
    with arcpy.da.InsertCursor("d:/projects/SolidWaste/SolidWaste.sde/SolidWaste.DBO.cayServiceOrders", ["RouteNumber","RouteDescription","StartDate","RouteOrder","StreetAddress","ServiceItemType","SerialNumber","X","Y","ItemUse","RouteNote","AccountNumber","AccountStatus","ServiceItemID","SHAPE@XY"]) as insertSO:
        routeNote = " "
        if row[10] is not None:
            routeNote = row[10][:120]
        insertSO.insertRow((row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],routeNote,row[11],row[12],row[13],(row[7],row[8])))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2025 23:51:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594569#M73894</guid>
      <dc:creator>RandyBonds_Jr_</dc:creator>
      <dc:date>2025-03-11T23:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: da.InsertCursor super slow</title>
      <link>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594581#M73895</link>
      <description>&lt;P&gt;It's extremely likely the cause is instantiating the cursor for each key in the dictionary, that's an expensive operation each time.&lt;BR /&gt;&lt;BR /&gt;Simply instantiate the cursor once, and have the dictionary iteration below/within the cursor.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fc = "d:/projects/SolidWaste/SolidWaste.sde/SolidWaste.DBO.cayServiceOrders"

with arcpy.da.InsertCursor(fc, [
    "RouteNumber", "RouteDescription", "StartDate", "RouteOrder",
    "StreetAddress", "ServiceItemType", "SerialNumber", "X", "Y",
    "ItemUse", "RouteNote", "AccountNumber", "AccountStatus",
    "ServiceItemID", "SHAPE@XY"
]) as insertSO:

    x = 0
    for row in routeRunRows:
        if (x % 1000) == 0:
            message = f"{x} Processed..."
            show_py_message()
        x += 1

        routeNote = row[10][:120] if row[10] else " "

        # Insert row
        insertSO.insertRow((
            row[0], row[1], row[2], row[3], row[4], row[5], row[6],
            row[7], row[8], row[9], routeNote, row[11], row[12],
            row[13], (row[7], row[8])
        ))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 12 Mar 2025 00:53:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594581#M73895</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2025-03-12T00:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: da.InsertCursor super slow</title>
      <link>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594732#M73898</link>
      <description>&lt;P&gt;I'll give that a try. I'm curious if you could explain why that makes a difference? Isn't it just a string?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 14:45:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594732#M73898</guid>
      <dc:creator>RandyBonds_Jr_</dc:creator>
      <dc:date>2025-03-12T14:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: da.InsertCursor super slow</title>
      <link>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594745#M73899</link>
      <description>&lt;P&gt;Never mind, I read that wrong. I see what you're talking about. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 15:00:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594745#M73899</guid>
      <dc:creator>RandyBonds_Jr_</dc:creator>
      <dc:date>2025-03-12T15:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: da.InsertCursor super slow</title>
      <link>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594790#M73902</link>
      <description>&lt;P&gt;Ah ok haha that's good.&amp;nbsp; I'll add my thinking anyway, but I could be wrong.&lt;BR /&gt;&lt;BR /&gt;1.&amp;nbsp; Every cursor establishes a new data connection.&amp;nbsp; This can be painful depending on where your data resides e.g. if it's in an SDE over VPN etc.&lt;BR /&gt;&lt;BR /&gt;2.&amp;nbsp; Data schema is read and validated every time, again and again.&amp;nbsp; Nowhere near as bad as point number 1, but it's not exactly going to make things faster.&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 16:14:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1594790#M73902</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2025-03-12T16:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: da.InsertCursor super slow</title>
      <link>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1595186#M73906</link>
      <description>&lt;P&gt;Final update on this thing. Thanks A TON! The script now runs in 10 seconds!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 15:06:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-insertcursor-super-slow/m-p/1595186#M73906</guid>
      <dc:creator>RandyBonds_Jr_</dc:creator>
      <dc:date>2025-03-13T15:06:04Z</dc:date>
    </item>
  </channel>
</rss>

