Thanks to all who responded. After considering your replies and advice, I wrote the following bash shell script to perform the batch analyze operation. I've tested it on my ArcSDE instance of ~1300 objects, and found that it works pretty well in my environment. I'm releasing what I've created back to the community in hopes that someone else will find it useful. I've tried to generalize the script as much as possible to facilitate reuse by allowing users to configure the necessary input parameters up front. If this is the wrong place for this (ArcScripts, perhaps?) I can post it elsewhere. Any comments and suggestions for improvement are welcome.
#!/bin/bash
##########################################################################
# Batch analyze script
# Query ArcSDE to get a list of all datasets in the database, then
# iterate through each owner.dataset to update DBMS statistics (ANALYZE).
# Output is logged to a file and optionally, a summary may be e-mailed to
# the ArcSDE administrator.
# Tested to work with ArcSDE/Oracle on RHEL 5.
# Author: Seth Peery, Virginia Polytechnic Institute and State University
# E-mail: sspeery@vt.edu
# Last Modified 2011-04-15
# Licensed under a Creative Commons Attribution 3.0 Unported License
# http://creativecommons.org/licenses/by/3.0/
##########################################################################
# PREREQUISITE:
# Set the following variables to match your environment
# N.B. be sure to chmod the referent of PASSWORDFILE to 600!
OUT_DIR=/path/to/script/output # logfile destination
PASSWORDFILE=$OUT_DIR/sdepass.txt # a single-line file with sde password
SERVER_NAME="myserver.example.com" # hostname of SDE server
DBMS_INSTANCE="my_TNS_entry" # TNS entry for SDE's Oracle Instance
SEND_EMAIL=true # set to true to send $SUMMARYFILE
ADMIN_EMAIL="foo@example.com" # admin's e-mail address
LAYERLIST=/tmp/allsdelayers.txt # no real need to change this
# Now, process the above to set password and output location variables.
PASSWORD=$(cat $PASSWORDFILE | head -n 1)
LOGFILE=$OUT_DIR/analyze_log_$(date +%F)
SUMMARYFILE=$OUT_DIR/analyze_summary_$(date +%F)
# Write the opening banner. Note that the first line truncates
# any existing logfile with the same name.
# If you want this to operate silently,
# replace 'tee -a' with '>>' and 'tee' with '>'.
echo '********************************************' | tee $SUMMARYFILE $LOGFILE
echo '******* ArcSDE Batch Analyze Utility *******' | tee -a $SUMMARYFILE $LOGFILE
echo '********************************************' | tee -a $SUMMARYFILE $LOGFILE
echo 'Analyze operation initiated ' $(date) | tee -a $SUMMARYFILE $LOGFILE
echo "Logging output to $LOGFILE" | tee -a $SUMMARYFILE
# Here's the SQL command we send to SQL*PLUS
# to get a list of all the objects in sde.table_registry
{
echo "set pagesize 0";
echo "set feedback off";
echo "select owner || '.' || table_name from table_registry order by owner, table_name;";
} | sqlplus -s sde/$PASSWORD@$DBMS_INSTANCE > $LAYERLIST;
echo 'Processing' $(cat $LAYERLIST | wc -l ) 'layers...' | tee -a $SUMMARYFILE
echo 'Any errors encountered during this process will be listed below.' | tee -a $SUMMARYFILE
echo '----------------------------------------------------------------' | tee -a $SUMMARYFILE
# Iterate through the layer list and run sdetable -o update_dbms_stats.
numLayers=0
numProcessedOK=0
for i in $(cat $LAYERLIST);
do
# Attempt to run Analyze on each layer
sdetable -o update_dbms_stats -u sde -p $PASSWORD -t $i &> /tmp/dbstats.out;
# Test for errors by grepping for the string "Error"
errorsPresent=$(grep Error /tmp/dbstats.out | wc -l)
let numLayers=$numLayers+1
if [ $errorsPresent -gt 0 ];
then
# Log the ArcSDE error messages (anything that says "Error")
grep Error /tmp/dbstats.out | tee -a $LOGFILE $SUMMARYFILE
else
# Log the last line of ArcSDE dbms_stats command output
# as our indication of success
tail -n 1 /tmp/dbstats.out >> $LOGFILE
let numProcessedOK=$numProcessedOK+1
fi
done
echo '----------------------------------------------------------------' | tee -a -a $SUMMARYFILE
echo 'Done.'
echo $numProcessedOK layers out of $numLayers analyzed OK. | tee -a $SUMMARYFILE $LOGFILE
echo 'Analyze operation completed' $(date) | tee -a $SUMMARYFILE $LOGFILE
if [ "$SEND_EMAIL" == "true" ];
then
SUBJECT="$SERVER_NAME Analyze log for $(date +%F)"
EMAIL=$ADMIN_EMAIL
EMAILMESSAGE=$SUMMARYFILE
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
fi
___________________________________________________Seth PeerySenior GIS Architect, Enterprise GISVirginia Tech Geospatial Information SciencesVirginia Polytechnic Institute and State University