AnsweredAssumed Answered

Rebuild Indexes -- What happens with no in_datasets passed?

Question asked by kesselbaump on Oct 14, 2014
Latest reply on Oct 31, 2014 by rbrennan-esristaff

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!

Outcomes