<?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 Python performance... in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-performance/m-p/135690#M10654</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;One of the improvements I had heard about at this years UC was the speed of python at 10.1.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have python process that I run to import data from our county assessors office ( they still use coverages...) into our geodatabase for our own evil purposes.&amp;nbsp; This takes about 6 hours to process on our old GIS server.&amp;nbsp; So I was very interested to see how fast this would go on a new server with a faster processor, more memory, enterprise database and a much faster python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is actually slower and bails out of the process in the middle.&amp;nbsp; The python memory footprint is about 1.7gb. So it looks like some sort of memory leak.&amp;nbsp; I reviewed my python code and it appears to be ok.&amp;nbsp; It is identical to what is running on my production server except that it writes to a different geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The process reads the parcel shape file and associated datasets and uses and insertcursor to put them into the geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have I found a but or do I have some bad code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Dec 2011 16:29:29 GMT</pubDate>
    <dc:creator>TomSellsted</dc:creator>
    <dc:date>2011-12-13T16:29:29Z</dc:date>
    <item>
      <title>Python performance...</title>
      <link>https://community.esri.com/t5/python-questions/python-performance/m-p/135690#M10654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;One of the improvements I had heard about at this years UC was the speed of python at 10.1.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have python process that I run to import data from our county assessors office ( they still use coverages...) into our geodatabase for our own evil purposes.&amp;nbsp; This takes about 6 hours to process on our old GIS server.&amp;nbsp; So I was very interested to see how fast this would go on a new server with a faster processor, more memory, enterprise database and a much faster python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is actually slower and bails out of the process in the middle.&amp;nbsp; The python memory footprint is about 1.7gb. So it looks like some sort of memory leak.&amp;nbsp; I reviewed my python code and it appears to be ok.&amp;nbsp; It is identical to what is running on my production server except that it writes to a different geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The process reads the parcel shape file and associated datasets and uses and insertcursor to put them into the geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have I found a but or do I have some bad code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2011 16:29:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-performance/m-p/135690#M10654</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2011-12-13T16:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python performance...</title>
      <link>https://community.esri.com/t5/python-questions/python-performance/m-p/135691#M10655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Tom, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What was the error mesage you saw when the tool failed?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One thing I spotted in your showGpMessage method; just convert that last call to arcpy.GetMessages()&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def showGpMessage():
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages())
&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;gt;&amp;gt; open(logFile, 'a'), arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.GetMessages()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A couple of things that would give you a time boost ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Remove the UpdateCursor and replace with the TruncateTable_management.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Update the script to use cursors in the arcpy.da module (although this is not a direct swap, the signature and techniques vary some).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Dave&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:34:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-performance/m-p/135691#M10655</guid>
      <dc:creator>DavidWynne</dc:creator>
      <dc:date>2021-12-11T07:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python performance...</title>
      <link>https://community.esri.com/t5/python-questions/python-performance/m-p/135692#M10656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;David,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for the information.&amp;nbsp; Interesting too.&amp;nbsp; I had made a bad assumption that the cursors would just be faster.&amp;nbsp; I will check into the DA module and see if it will help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I ran a couple of experiments with my existing code and it still looks like there is some sort of memory leak.&amp;nbsp; I get an error message stating:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime Error!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Program: c:\Python27\ArcGIS10.1\pythonw.exe&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;abnormal program termination&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Dec 2011 16:49:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-performance/m-p/135692#M10656</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2011-12-14T16:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python performance...</title>
      <link>https://community.esri.com/t5/python-questions/python-performance/m-p/135693#M10657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks very much for the information.&amp;nbsp; Interesting too.&amp;nbsp; I had made a bad assumption that the cursors would just be faster.&amp;nbsp; I will check into the DA module and see if it will help.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Tom,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There will be some improvement in the speed of the 'classic' cursors, but more of a matter of degree. However, the new arcpy.da cursors will typically show multiple factors of improvement performance-wise over the classic cursors.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Dave&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Dec 2011 17:05:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-performance/m-p/135693#M10657</guid>
      <dc:creator>DavidWynne</dc:creator>
      <dc:date>2011-12-14T17:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python performance...</title>
      <link>https://community.esri.com/t5/python-questions/python-performance/m-p/135694#M10658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Six hours! :rolleyes:I hope you found the bottleneck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That would break my personal "Cup of Coffee Rule":&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;"If any single process takes longer than a cup of coffee, interrupt it and &lt;SPAN style="font-style:italic;"&gt;find a better way&lt;/SPAN&gt;".&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Since you are also running out of memory, finding what is causing that will probably speed things up enormously as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I like TruncateTable_management. I note that there is no help in the Beta for this new utility Esri, ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You don't say how many records you have, but I would expect a couple of million records to take less than half an hour.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Suggestions to find the problem, don't give up until you can have that cup of coffee while it is still hot:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I immediately see a red flag where you open SDE which will inevitably be across a sloooow network, or at least it will be using&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sloow handshaking. Could you try loading into a filegeodatabase on a local drive and then copy the file geodatabase in a single step?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe FME (or Data Interoperability Extension) might be faster?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe load the shapefiles separately directly into a filegeodatabase and then use some SQL queries to do the selection and editing,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;instead of doing it all with the cursor. Very large records with many fields will be slow to load into a database. You could use MakeQueryTable to create a subset and then write out the view to SDE.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does the database have any indexes? You should drop the indexes when you truncate otherwise every insert will trigger a re-index.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Does it get slower with more data. Try loading the first 10% to see if that is faster in proportion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even though you are careful to trigger a garbage collection with del statements, it clearly isn't working. Have a look at your memory usage using Task Manager.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If it keeps going up, then that might be the solution. If you can restructure the script to use a function, sometimes that garbage collects better.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You might be more successful if you could batch the transactions. The cursors are a bit simple here. But FME can do this better.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I find using Python and tools with more than a million records hits some sort of limit, even with my 8 CPU workstation. So I partition the work to use less than 1M records and it completes in a few minutes instead of never. Even for aspatial SQL queries.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2012 07:19:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-performance/m-p/135694#M10658</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2012-02-08T07:19:16Z</dc:date>
    </item>
  </channel>
</rss>

