Analyze Datasets (Data Management)

Summary

Updates database statistics of base tables, delta tables, and archive tables, along with the statistics on the indexes of those tables. This tool is used in enterprise geodatabases to help get optimal performance from the RDBMS query optimizer. Stale statistics can affect geodatabase performance.

Usage

  • The input workspace must be a database or enterprise geodatabase. The Analyze Datasets tool does not work with file or mobile geodatabases.

  • After data loading, deleting, updating, and compressing operations, it is important to update RDBMS statistics in the database.

  • The Include System Tables option is used to determine if the states and state lineage tables will be analyzed. These tables track traditional versions. When this option is not selected, the tables are not analyzed; when it's 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 the indexes of those tables.

  • The Add Value button of the Datasets to Analyze parameter is used only in ModelBuilder. In ModelBuilder, when 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.

  • This tool is not supported for use on SAP HANA.

Parameters

LabelExplanationData Type
Input Database Connection

The database that contains the data to be analyzed.

Workspace
Include System Tables

Specifies whether statistics will be gathered on the states and state lineages tables.

  • Unchecked—Statistics will not be gathered on the states and state lineages tables. This is the default.
  • Checked—Statistics will be gathered on the states and state lineages tables.
    Note:

    You must be the geodatabase administrator for this option to be active.

    This option only applies to geodatabases. If the input workspace is a database, this option will be inactive.

Boolean
Datasets to Analyze
(Optional)

The names of the datasets that will be analyzed. Only datasets that are owned by the connected user will be displayed.

String
Analyze Base Tables for Selected Dataset(s)
(Optional)

Specifies whether the selected dataset base tables will be analyzed.

Note:
This option only applies to geodatabases. If the input workspace is a database, this option will be inactive.

  • Checked—Statistics will be gathered for the base tables for the selected datasets. This is the default.
  • Unchecked—Statistics will not be gathered for the base tables for the selected datasets.
Boolean
Analyze Delta Tables for Selected Dataset(s)
(Optional)

Specifies whether the selected dataset delta tables will be analyzed.

Note:
This option only applies to geodatabases that contain traditional versions. If the input workspace is a database, this option will be inactive.

  • Checked—Statistics will be gathered for the delta tables for the selected datasets. This is the default.
  • Unchecked—Statistics will not be gathered for the delta tables for the selected datasets.
Boolean
Analyze Archive Tables for Selected Dataset(s)
(Optional)

Specifies whether the selected dataset archive tables will be analyzed.

Note:
This option only applies to geodatabases that contain archive-enabled datasets. If the input workspace is a database, this option will be inactive.

  • Checked—Statistics will be gathered for the archive tables for the selected datasets. This is the default.
  • Unchecked—Statistics will not be gathered for the archive tables for the selected datasets.
Boolean

Derived Output

LabelExplanationData Type
Updated Workspace

The updated workspace.

Workspace

arcpy.management.AnalyzeDatasets(input_database, include_system, {in_datasets}, {analyze_base}, {analyze_delta}, {analyze_archive})
NameExplanationData Type
input_database

The database that contains the data to be analyzed.

Workspace
include_system

Specifies whether statistics will be gathered on the states and state lineages tables.

Note:

You must be the geodatabase administrator for this option to be active.

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)

The names of the datasets that will be analyzed. An individual dataset or a Python list of datasets can be used. Dataset names use paths relative to the input workspace; full paths are not accepted as input.

The connected user must be the owner of the datasets provided.

String
analyze_base
(Optional)

Specifies 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 for 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)

Specifies whether the selected dataset delta tables will be analyzed.

This option only applies to geodatabases that contain traditional versions. If the input workspace is a database, this option will be ignored.

  • ANALYZE_DELTA Statistics will be gathered for 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)

Specifies whether the selected dataset archive tables will be analyzed.

This option only applies to geodatabases that contain archive-enabled datasets. If the input workspace is a database, this option will be ignored.

  • ANALYZE_ARCHIVE Statistics will be gathered for 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

Derived Output

NameExplanationData Type
out_workspace

The updated workspace.

Workspace

Code sample

AnalyzeDatasets example 1 (Python window)

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")
AnalyzeDatasets example 2 (stand-alone script)

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

Related topics