Select to view content in your preferred language

Rebuild Indexes -- What happens with no in_datasets passed?

4247
3
10-14-2014 08:01 AM
PerryKesselbaum
Deactivated User

I have consulted this help doc: ArcGIS Help (10.2, 10.2.1, and 10.2.2) on rebuilding indexes. I am unclear as to what happens when I pass an empty string for in_datasets. Does this rebuild indexes on every dataset available to that input DB Connection?

The reason I ask is because I have a script that generates a list of datasets in my SDE, then rebuilds indexes on all of them (very much like the example code listed in the help doc above):

##get datasets

    data_list = arcpy.ListTables() + arcpy.ListFeatureClasses()

    for dataset in arcpy.ListDatasets("", "Feature"):

        env.workspace = os.path.join(workspace, dataset)

        data_list += arcpy.ListFeatureClasses() + arcpy.ListDatasets()

    ##Rebuild indexes

    env.workspace = workspace

    try:

        arcpy.RebuildIndexes_management(workspace, "SYSTEM", data_list, "ALL")

        emailMessage += "<br>indexes rebuilt"

    except:

        emailMessage += "<br>Rebuild indexes failed. " + time.asctime()

        traceback.print_exc(file=log)

where workspace is a variable pointing to my .sde connection file for the DB owner (sde user).

This code worked without errors for several weeks. Since upgrading from 10.1 to 10.2.2, When I pass data_list, I get permission/not found errors for each dataset:

ExecuteError: Could not rebuild indexes for dataset  ... [Operation Failed [42000:[Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot find the object ... because it does not exist or you do not have permissions.]]

However, when I've tried running the script passing an empty string instead of data_list, it runs without an error. I am hoping that I can work around the ExecuteError by skipping the in_datasets argument all together.

Is passing '' instead of my full list of datasets accomplishing the same index rebuilding, or do I need to pass the whole list to rebuild indexes on each dataset in the DB?

As a side question, where is the geoprocessing tool in the script getting its permissions? Is it from the .sde connection file or is it from the user who is executing the script?

Thanks!

0 Kudos
3 Replies
RussellBrennan
Esri Contributor

The Rebuild Indexes tool will rebuild indexes on two different 'types' of tables in your geodatabase. In the case of the rebuild indexes tool we have separated the tables into 'data tables' and 'system tables'. Data tables are the tables that you get returned when you run any of the list functions (like what you are doing in your script). System tables are those used by the geodatabase internally (states, state_lineages table for example).

Within the tool there is a parameter 'include_system' with options 'SYSTEM' and 'NO_SYSTEM'. When you choose 'SYSTEM' you need to be connected as the geodatabase administrator, because only the geodatabase administrator has privileges to update indexes on these tables. In some cases you may want to only update the system table indexes. You can do this by running the tool and providing the 'SYSTEM' parameter and NOT providing any other datasets in the in_datasets list. If you try to run the tool using 'NO_SYSTEM' and NOT providing any other datasets in the in_datasets list the tool will fail.

It appears that since you are using the SYSTEM parameter the tool is executing properly. Through Python we do not find all of the datasets that your user owns and automatically update indexes, you need to provide the list.

To answer your side question, when using geoprocessing/python the permissions are coming from the .sde connection file. In the case that you are using Operating System Authentication in your .sde connection file the permissions will then come from the OS user who is running the script.

BlakeTerhune
MVP Regular Contributor

Does this work the same way for Analyze Datasets?

0 Kudos
RussellBrennan
Esri Contributor

Yes

0 Kudos