<?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: Performance enhancement options for querying file geo-database in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/performance-enhancement-options-for-querying-file/m-p/268148#M20656</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One suggestion is to be sure to clean up the in_memory space prior to and post process run(s) to each iteration, otherwise you may end up consuming available RAM (I believe this is where in_memory is written to).&amp;nbsp; I include this def() in most of my tools and can just call it anytime/anywhere needed, especially if all your processing is intermediate data -- so you would need to write the "final" output to disk.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

def clearINMEM():


&amp;nbsp; arcpy.env.workspace = r"IN_MEMORY"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; fcs = arcpy.ListFeatureClasses()
&amp;nbsp; tabs = arcpy.ListTables()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; ### for each FeatClass in the list of fcs's, delete it.
&amp;nbsp; for f in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(f)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("deleted: " + f)



&amp;nbsp; ### for each TableClass in the list of tab's, delete it.
&amp;nbsp; for t in tabs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(t)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("deleted: " + t)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:08:12 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2021-12-11T13:08:12Z</dc:date>
    <item>
      <title>Performance enhancement options for querying file geo-database</title>
      <link>https://community.esri.com/t5/python-questions/performance-enhancement-options-for-querying-file/m-p/268147#M20655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello - We are using ArcGIS 10.0 (Python 2.6).&amp;nbsp; We are using a file geo-database which has 400+ feature classes (polygon features) which contain a total of about 400,000 features.&amp;nbsp; Some feature classes only have a few features while other have 10s of thousands.&amp;nbsp; The UI allows the user to selected an AOI extent.&amp;nbsp; On the server, we are using arcpy to perform an INTERSECTS search using the AOI extent.&amp;nbsp; How it works is that it goes though a loop for each of the 400+ feature classes and performs the INTERSECTS search.&amp;nbsp; This can take a couple of minutes to run.&amp;nbsp; I am wondering if there is a more efficient way to perform the search.&amp;nbsp; I am not sure if it just the case where you have to run the search against each of the feature classes, one at a time.&amp;nbsp; Initially I was thinking that there may be a way to perform a single seach over all of the feature classes, but was told that option was not really feasible.&amp;nbsp; So the first question is whether or not I simply have to stick with doing 400+ individual searches.&amp;nbsp; If the answer is yes, then I am wondering if the manner in which it is being done is at least efficient.&amp;nbsp; The process for EACH feature class is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;feature_layer = "in_memory\\" + layer_name&lt;/P&gt;&lt;P&gt;fc_path = main_gdb + "/" + layer_name&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management(fc_path, feature_layer)&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByLocation_management(feature_layer, "INTERSECT", aoi, "", "NEW_SELECTION")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may be that all is the best it can be.&amp;nbsp; I am just hoping that there is way to speed up the searches in some manner.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts would be greatly appreciated - Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 19:49:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/performance-enhancement-options-for-querying-file/m-p/268147#M20655</guid>
      <dc:creator>PeterLen</dc:creator>
      <dc:date>2014-09-25T19:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Performance enhancement options for querying file geo-database</title>
      <link>https://community.esri.com/t5/python-questions/performance-enhancement-options-for-querying-file/m-p/268148#M20656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One suggestion is to be sure to clean up the in_memory space prior to and post process run(s) to each iteration, otherwise you may end up consuming available RAM (I believe this is where in_memory is written to).&amp;nbsp; I include this def() in most of my tools and can just call it anytime/anywhere needed, especially if all your processing is intermediate data -- so you would need to write the "final" output to disk.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

def clearINMEM():


&amp;nbsp; arcpy.env.workspace = r"IN_MEMORY"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; fcs = arcpy.ListFeatureClasses()
&amp;nbsp; tabs = arcpy.ListTables()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; ### for each FeatClass in the list of fcs's, delete it.
&amp;nbsp; for f in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(f)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("deleted: " + f)



&amp;nbsp; ### for each TableClass in the list of tab's, delete it.
&amp;nbsp; for t in tabs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(t)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("deleted: " + t)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:08:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/performance-enhancement-options-for-querying-file/m-p/268148#M20656</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T13:08:12Z</dc:date>
    </item>
  </channel>
</rss>

