<?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: Improving the speed of arcpy.ChangeVersion_management in ArcGIS Pro in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202875#M65312</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/242657"&gt;@PhilLarkin1&lt;/a&gt;&amp;nbsp;, I found a workaround that seems fast. Create a new version then create a temporary connection file avoiding the slog of trying to change the version.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:
    #  Check if version name already exists - use existing one if found or create a new one
    arcpy.SetProgressorLabel("Processing EGDB requirements")
    version_list = [sde_version.name for sde_version in arcpy.da.ListVersions(sde_path)]
    if full_version_name not in version_list:
        arcpy.AddMessage("Creating new version of sde.default")
        arcpy.CreateVersion_management(sde_path, parent_version, version_name, "PUBLIC")
    else:
        arcpy.AddMessage("Version already exists - writing to existing version")
    arcpy.AddMessage("Creating temporary connection file")
    #  Check if temp username folder exists, if not create in the staging area.
    #  The temp user folder is used to store the temp connection file.
    staging_user_folder_path = os.path.join(staging_folder, get_current_user())
    if not os.path.exists(staging_user_folder_path):
        os.mkdir(staging_user_folder_path)
    #  Create temporary connection file in the user folder that connects to the version
    arcpy.CreateDatabaseConnection_management(
        staging_user_folder_path, f"{version_name}.sde", "ORACLE",
        f"{os.path.basename(sde_path_split[0])}/{os.path.basename(sde_path_split[0])}", "OPERATING_SYSTEM_AUTH",
        None, None, None, None, None, "TRANSACTIONAL", full_version_name)
    temp_sde_path = os.path.join(staging_user_folder_path, f"{version_name}.sde")
    temp_sde_fc_path = os.path.join(temp_sde_path, sde_fs_fc_name)
except arcpy.ExecuteError:
    exec_error()
except:
    traceback_error()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Aug 2022 15:08:00 GMT</pubDate>
    <dc:creator>MattHowe</dc:creator>
    <dc:date>2022-08-15T15:08:00Z</dc:date>
    <item>
      <title>Improving the speed of arcpy.ChangeVersion_management in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1078603#M61729</link>
      <description>&lt;P&gt;I'm creating a script that includes a section that appends a feature from the 'memory' workspace to a newly created version of our SDE.DEFAULT database. When running the script I've noticed that the arcpy.ChangeVersion_management geoprocessing tool is cripplingly slow, just to switch to the new version. In addition, appending one feature to the new version if also painfully slow. The code is below but does anyone have any ideas as to how it can be speeded up?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if upload_to_SDE == "true":
    arcpy.SetProgressorLabel("Preparing new SDE version")
    arcpy.AddMessage("Creating SDE version")
    try:
        arcpy.env.workspace = sde_path
        parent_version = "SDE.DEFAULT"
        version_name = "TEST_VERSION"
        sde_fl = "SurveyAreaFL"
        full_version_name = f"OPS${get_current_user()}.{version_name}"
        # Create new version for the new extent
        arcpy.CreateVersion_management(sde_path, parent_version, version_name, "PUBLIC")
        arcpy.AddMessage(f"Version: {full_version_name} created")
        arcpy.management.MakeFeatureLayer(survey_area_path, sde_fl)
        arcpy.SetProgressorLabel("Changing version")
        arcpy.ChangeVersion_management(sde_fl, "TRANSACTIONAL", full_version_name)
        arcpy.AddMessage(f"Version changed: ADM.SurveyArea {full_version_name}")
        arcpy.SetProgressorLabel("Appending features")
        arcpy.Append_management(r"memory\NewSurveyArea", sde_fl, "TEST")
        arcpy.AddMessage("Data appended to SDE: SurveyArea")
    except arcpy.ExecuteError:
        exec_error()
    except:
        traceback_error()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 10:13:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1078603#M61729</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2021-07-14T10:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Improving the speed of arcpy.ChangeVersion_management in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1079000#M61767</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/129401"&gt;@KoryKramer&lt;/a&gt;&amp;nbsp;'s post provides tips on performance problems&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-documents/troubleshooting-performance-issues-in-arcgis-pro/ta-p/1025516/jump-to/first-unread-message" target="_blank"&gt;Troubleshooting Performance Issues in ArcGIS Pro - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;or&amp;nbsp;&lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-pro/announcements/announcing-the-arcgis-pro-performance-assessment-tool-pat/" target="_blank"&gt;Announcing the ArcGIS Pro Performance Assessment Tool (PAT) (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;other than that, working with Tech Support may be your remaining option.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 23:01:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1079000#M61767</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-07-14T23:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Improving the speed of arcpy.ChangeVersion_management in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202082#M65290</link>
      <description>&lt;P&gt;I've noticed that ChangeVersion is very slow as well.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 18:22:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202082#M65290</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2022-08-11T18:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Improving the speed of arcpy.ChangeVersion_management in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202875#M65312</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/242657"&gt;@PhilLarkin1&lt;/a&gt;&amp;nbsp;, I found a workaround that seems fast. Create a new version then create a temporary connection file avoiding the slog of trying to change the version.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:
    #  Check if version name already exists - use existing one if found or create a new one
    arcpy.SetProgressorLabel("Processing EGDB requirements")
    version_list = [sde_version.name for sde_version in arcpy.da.ListVersions(sde_path)]
    if full_version_name not in version_list:
        arcpy.AddMessage("Creating new version of sde.default")
        arcpy.CreateVersion_management(sde_path, parent_version, version_name, "PUBLIC")
    else:
        arcpy.AddMessage("Version already exists - writing to existing version")
    arcpy.AddMessage("Creating temporary connection file")
    #  Check if temp username folder exists, if not create in the staging area.
    #  The temp user folder is used to store the temp connection file.
    staging_user_folder_path = os.path.join(staging_folder, get_current_user())
    if not os.path.exists(staging_user_folder_path):
        os.mkdir(staging_user_folder_path)
    #  Create temporary connection file in the user folder that connects to the version
    arcpy.CreateDatabaseConnection_management(
        staging_user_folder_path, f"{version_name}.sde", "ORACLE",
        f"{os.path.basename(sde_path_split[0])}/{os.path.basename(sde_path_split[0])}", "OPERATING_SYSTEM_AUTH",
        None, None, None, None, None, "TRANSACTIONAL", full_version_name)
    temp_sde_path = os.path.join(staging_user_folder_path, f"{version_name}.sde")
    temp_sde_fc_path = os.path.join(temp_sde_path, sde_fs_fc_name)
except arcpy.ExecuteError:
    exec_error()
except:
    traceback_error()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 15:08:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202875#M65312</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2022-08-15T15:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Improving the speed of arcpy.ChangeVersion_management in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202878#M65314</link>
      <description>&lt;P&gt;Oooh, good idea! Looking forward to trying this out.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 15:12:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202878#M65314</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2022-08-15T15:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Improving the speed of arcpy.ChangeVersion_management in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202960#M65319</link>
      <description>&lt;P&gt;This method took about a minute, which is a vast improvement over changing the version per layer. Thanks for the suggestion!&lt;BR /&gt;&lt;BR /&gt;I used updateConnectionProperties to change the version.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;project = arcpy.mp.ArcGISProject("CURRENT")
map = project.listMaps(&amp;lt;mapName&amp;gt;)[0]
sdePath == "file\path\to\layer\sdefile"
editVersionConnFile = arcpy.management.CreateDatabaseConnection(out_folder_path = project.homeFolder, out_name = versionName, database_platform = "SQL_SERVER",instance = "&amp;lt;server&amp;gt;\\&amp;lt;instance&amp;gt;", account_authentication = "OPERATING_SYSTEM_AUTH",database = "&amp;lt;database&amp;gt;", version_type = "TRANSACTIONAL", version = versionName)
map.updateConnectionProperties(current_connection_info = sdePath, new_connection_info = editVersionConnFile)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 17:25:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202960#M65319</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2022-08-15T17:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Improving the speed of arcpy.ChangeVersion_management in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202977#M65321</link>
      <description>&lt;P&gt;Great stuff!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 17:56:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/improving-the-speed-of-arcpy-changeversion/m-p/1202977#M65321</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2022-08-15T17:56:41Z</dc:date>
    </item>
  </channel>
</rss>

