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 relational database management system (RDBMS) query optimizer. Stale statistics can affect geodatabase performance.

Usage

  • The input workspace must be a database or enterprise geodatabase.

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

  • The Include System Tables parameter is used to determine whether the states and state lineage tables will be analyzed. These tables track traditional versions. When this parameter is not checked, the tables are not analyzed; when it's checked, the tables are analyzed.

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 parameter to be active.

    This parameter only applies to geodatabases. If the input workspace is a database, this parameter 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 parameter only applies to geodatabases. If the input workspace is a database, this parameter 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 parameter only applies to geodatabases that contain traditional versions. If the input workspace is a database or does not participate in traditional versioning, this parameter 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 parameter only applies to geodatabases that contain archive-enabled datasets. If the input workspace is a database, this parameter 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 to use this parameter.

This parameter only applies to geodatabases. If the input workspace is a database, this parameter 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 valid 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 parameter only applies to geodatabases. If the input workspace is a database, this parameter 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 parameter only applies to geodatabases that contain traditional versions. If the input workspace is a database or does not participate in traditional versioning, this parameter 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 parameter only applies to geodatabases that contain archive-enabled datasets. If the input workspace is a database, this parameter 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 function 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 function 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 = "C:\\MyProject\\MyDataConnection.sde"

# set the workspace environment
arcpy.env.workspace = workspace

# NOTE: Analyze Datasets can accept a Python list of datasets.

# Get the user name for the workspace
userName = arcpy.Describe(workspace).connectionProperties.user

# Get a list of all the datasets the user owns by using a wildcard that incldues the user name
# First, get all the stand alone tables, feature classes and rasters.
dataList = arcpy.ListTables(userName + "*") + arcpy.ListFeatureClasses(userName + "*") + arcpy.ListRasters(userName + "*")

# 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(userName + "*", "Feature"):
    arcpy.env.workspace = os.path.join(workspace,dataset)
    dataList += arcpy.ListFeatureClasses(userName + "*") + arcpy.ListDatasets(userName + "*")

# reset the workspace
arcpy.env.workspace = workspace

# 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