Analyze Datasets (Data Management)

License Level:BasicStandardAdvanced

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

Syntax

AnalyzeDatasets_management (input_database, include_system, {in_datasets}, {analyze_base}, {analyze_delta}, {analyze_archive})
ParameterExplanationData 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.

NoteNote:

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.

  • NO_SYSTEMStatistics will not be gathered on the states and state lineages tables. This is the default.
  • SYSTEMStatistics will be gathered on the states and state lineages tables.
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.

  • ANALYZE_BASE Statistics will be gathered on the base tables for the selected datasets. This is the default.
  • NO_ANALYZE_BASE Statistics will not be gathered for the base tables for the selected datasets.
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.

  • ANALYZE_DELTA Statistics will be gathered on the delta tables for the selected datasets. This is the default.
  • NO_ANALYZE_DELTA Statistics will not be gathered for the delta tables for the selected datasets.
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.

  • ANALYZE_ARCHIVE Statistics will be gathered on the archive tables for the selected datasets. This is the default.
  • NO_ANALYZE_ARCHIVE Statistics will not be gathered for the archive tables for the selected datasets.
Boolean

Code Sample

AnalyzeDatasets example 1 (Python window)

The following Python window script demonstrates how to use the Analyze Datasets tool in immediate mode.

# Import system modules
import arcpy

arcpy.AnalyzeDatasets_management("Database Connections/tenone@sde.sde",
                                 "SYSTEM",
                                 "gdb.city;gdb.state;map.lines",
                                 "ANALYZE_BASE",
                                 "ANALYZE_DELTA",
                                 "ANALYZE_ARCHIVE")
AnalyzeDatasets example 2 (stand-alone script)

The following stand-alone script demonstrates how to use the Analyze Datasets 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, 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

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
11/18/2013