Summary
Updates database statistics of base tables, delta tables, and archive tables, along with the statistics on those tables' indexes. This tool is used in enterprise geodatabases to help get optimal performance from the RDBMS's query optimizer. Stale statistics can lead to poor geodatabase performance.
Usage
The input workspace must be an enterprise database. Analyze Datasets does not work with file or personal geodatabases.
After data loading, deleting, updating, and compressing operations, it is important to update RDBMS statistics in Oracle, SQL Server, DB2, or PostgreSQL databases.
The option Include System Tables is used to determine if the states and state lineage tables will be analyzed. When the option is unselected, these tables are not analyzed; when selected, the tables are analyzed.
When working with tables or datasets, this tool updates the statistics of base tables, delta tables, and archive tables, along with the statistics on those tables' indexes.
The Datasets to Analyze parameter's Add Value button is used only in ModelBuilder. In ModelBuilder, where the preceding tool has not been run, or its derived data does not exist, the Datasets to Analyze parameter may not be populated with values. The Add Value button allows you to add expected values so you can continue to build your model.
Syntax
arcpy.management.AnalyzeDatasets(input_database, include_system, {in_datasets}, {analyze_base}, {analyze_delta}, {analyze_archive})
Parameter | Explanation | Data Type |
input_database | The enterprise database that contains the data to be analyzed. | Workspace |
include_system | Indicates whether statistics will be gathered on the states and state lineages tables. Note:You must be the geodatabase administrator for this option to be activated. This option only applies to geodatabases. If the input workspace is a database, this option will be ignored.
| Boolean |
in_datasets [in_datasets,...] (Optional) | Names of the datasets that will be analyzed. An individual dataset or a Python list of datasets is allowed. Dataset names use paths relative to the input workspace; full paths are not accepted as input. Note that the connected user must be the data owner for the datasets provided. | String |
analyze_base (Optional) | Indicates whether the selected dataset base tables will be analyzed. This option only applies to geodatabases. If the input workspace is a database, this option will be ignored.
| Boolean |
analyze_delta (Optional) | Indicates whether the selected dataset delta tables will be analyzed. This option only applies to geodatabases. If the input workspace is a database, this option will be ignored.
| Boolean |
analyze_archive (Optional) | Indicates whether the selected dataset archive tables will be analyzed. This option only applies to geodatabases. If the input workspace is a database, this option will be ignored.
| Boolean |
Derived Output
Name | Explanation | Data Type |
out_workspace | The updated workspace. | Workspace |
Code sample
The following Python window script demonstrates how to use the AnalyzeDatasets tool in immediate mode.
# Import system modules
import arcpy
arcpy.AnalyzeDatasets_management("c:/Connections/tenone@sde.sde",
"SYSTEM",
"gdb.city;gdb.state;map.lines",
"ANALYZE_BASE",
"ANALYZE_DELTA",
"ANALYZE_ARCHIVE")
The following stand-alone script demonstrates how to use the AnalyzeDatasets tool to analyze all datasets for a given user connection.
# Name: AnalyzeDatasets.py
# Description: analyzes all datasets in an enterprise geodatabase
# for a given user.
# Import system modules
import arcpy
import os
# set workspace
# the user in this workspace must be the owner of the data to analyze.
workspace = arcpy.GetParameterAsText(0)
# set the workspace environment
arcpy.env.workspace = workspace
# NOTE: Analyze Datasets can accept a Python list of datasets.
# Get a list of all the datasets the user has access to.
# First, get all the stand alone tables, feature classes and rasters.
dataList = arcpy.ListTables() + arcpy.ListFeatureClasses() + arcpy.ListRasters()
# Next, for feature datasets get all of the datasets and featureclasses
# from the list and add them to the master list.
for dataset in arcpy.ListDatasets("", "Feature"):
arcpy.env.workspace = os.path.join(workspace,dataset)
dataList += arcpy.ListFeatureClasses() + arcpy.ListDatasets()
# reset the workspace
arcpy.env.workspace = workspace
# Get the user name for the workspace
userName = arcpy.Describe(workspace).connectionProperties.user.lower()
# remove any datasets that are not owned by the connected user.
userDataList = [ds for ds in dataList if ds.lower().find(".%s." % userName) > -1]
# Execute analyze datasets
# Note: to use the "SYSTEM" option the workspace user must be an administrator.
arcpy.AnalyzeDatasets_management(workspace, "NO_SYSTEM", dataList, "ANALYZE_BASE","ANALYZE_DELTA","ANALYZE_ARCHIVE")
print("Analyze Complete")
Environments
Licensing information
- Basic: No
- Standard: Yes
- Advanced: Yes