sp_showoptstats

Similar in function to the optdiag standalone utility in an XML document but in a system procedure format, sp_showoptstats extracts and displays statistics and histograms for various data objects from system tables such as systabstats and sysstatistics.

Syntax

sp_showoptstats  
[[database_name.[owner].]{table_name|prs_name}],[column_name], [h]

Parameters

Examples

Usage

There are additional considerations when using sp_showoptstats:
  • You cannot execute sp_showoptstats across databases.

  • sp_showoptstats does not include the system tables unless you explicitly specify them.

  • Nonprintable and univarchar characters appear in hexidecimal format.

  • sp_showoptstats displays both global and partition-level statistics.

  • When the output is larger than the value you set for @@textsize, the SAP ASE server returns a message to increase the @@textsize setting so that it can display the large output.

  • Parameter values that include a period (.) require double quotation marks.

  • You can issue sp_showoptstats against system tables.

  • sp_showoptstats does not return statistical information if you specify only the database and owner.

The DTD file for the XML output of sp_showoptstats is:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT optStats (procVersion, serverVersion, serverName?, specifiedDatabase?, specifiedTableOwner?, specifiedTable?, specifiedCol?, tables*)>
<!ELEMENT procVersion (#PCDATA)>
<!ELEMENT serverVersion (#PCDATA)>
<!ELEMENT serverName (#PCDATA)>
<!ELEMENT specifiedDatabase (#PCDATA)>
<!ELEMENT specifiedTableOwner (#PCDATA)>
<!ELEMENT specifiedTable (#PCDATA)>
<!ELEMENT specifiedCol (#PCDATA)>

<!ELEMENT tables (tableOwner, tableName, partitionCnt?, (tableStats|clusteredIndStats|indStats|partitionStats|partitionClusteredIndStats|partitionIndStats)*,  (colStats|colPartitionStats)*, noStatsCol?)>

<!ELEMENT tableOwner (#PCDATA) >
<!ELEMENT tableName (#PCDATA) >  

<!ELEMENT tableStats (tableName, stats)>

<!ELEMENT clusteredIndStats (indName, colList, stats)>

<!ELEMENT indName (#PCDATA) >  
<!ELEMENT colList (#PCDATA) >  

<!ELEMENT partitionStats (partition*, stats*)>

<!ELEMENT partition (#PCDATA) >  

<!ELEMENT partitionIndStats (indName, partition, colList, stats)>

<!ELEMENT partitionClusteredIndStats (indName, partition, colList, stats)>

<!ELEMENT stats (pgCnt?, leafCnt?, (emptyPgCnt|emptyLeafCnt)?, CRCnt?, indCRCnt?, indPgCRCnt?, (dataRowCRCnt|leafRowCRCnt)?, rowCnt?, fwdRowCnt?, delRowCnt?, indPgCRCnt?, CRCnt?, oamAllocPgCnt?, (firstExtDataPgs|firstExtLeafPgs)?, (dataRowSz|leafRowSz)?, indHeight?, dataPages?, joinDegree?, unusedPgCnt?, oamPgCnt?, derivedStats?) > 

<!ELEMENT pgCnt (#PCDATA) >  
<!ELEMENT leafCnt (#PCDATA) >
<!ELEMENT CRCnt (#PCDATA) >  
<!ELEMENT indCRCnt (#PCDATA) >
<!ELEMENT dataRowCRCnt (#PCDATA) >  
<!ELEMENT leafRowCRCnt (#PCDATA) >  
<!ELEMENT emptyPgCnt (#PCDATA) >
<!ELEMENT emptyLeafCnt (#PCDATA) >
<!ELEMENT rowCnt (#PCDATA) >  
<!ELEMENT fwdRowCnt (#PCDATA) >
<!ELEMENT delRowCnt (#PCDATA) >  
<!ELEMENT oamAllocPgCnt (#PCDATA) >  
<!ELEMENT firstExtDataPgs (#PCDATA) >
<!ELEMENT firstExtLeafPgs (#PCDATA) >
<!ELEMENT dataRowSz (#PCDATA) >  
<!ELEMENT leafRowSz (#PCDATA) >  
<!ELEMENT indHeight (#PCDATA) >  
<!ELEMENT dataPages (#PCDATA) >  
<!ELEMENT joinDegree (#PCDATA) >
<!ELEMENT unusedPgCnt (#PCDATA) >  
<!ELEMENT oamPgCnt (#PCDATA) >
<!ELEMENT rowClusterRatio (#PCDATA) >

<!ELEMENT derivedStats (clusterRatio, indClusterRatio?, (dataClusterRatio|rowClusterRatio)?, spaceUtil?, IOEfficiency?) >  

<!ELEMENT clusterRatio (#PCDATA) >
<!ELEMENT indClusterRatio (#PCDATA) >
<!ELEMENT dataClusterRatio (#PCDATA) >
<!ELEMENT spaceUtil (#PCDATA) >  
<!ELEMENT IOEfficiency (#PCDATA) >

<!ELEMENT indStats (indName, colList, stats?) > 
	
<!ELEMENT colStats ((colName|colGroup)?, lastUpdate?, cellDensity?, totalDensity?, select?, inBetSel?, rangeVal?, totalVal?, avgColWidth?, 
statsVer? statsSamDen?, statsSamU?, histogram?) > 
	
<!ELEMENT colGroup (#PCDATA) >
<!ELEMENT lastUpdate (#PCDATA) >  
<!ELEMENT cellDensity (#PCDATA) >
<!ELEMENT totalDensity (#PCDATA) >  
<!ELEMENT selectivity (#PCDATA) >
<!ELEMENT inBetweenSelectivity (#PCDATA) >  
<!ELEMENT rangeVal (#PCDATA) >
<!ELEMENT totalVal (#PCDATA) >  
<!ELEMENT avgColWidth (#PCDATA) >
<!ELEMENT statsVer (#PCDATA) >
<!ELEMENT statsSamDen (#PCDATA) >
<!ELEMENT statsSamU (#PCDATA) >

<!ELEMENT colPartitionStats (ptnName,(colName|colGroup)?, lastUpdate?, cellDensity?, totalDensity?, select?, inBetSel?, rangeVal?, totalVal?, avgColWidth?, statsVer? statsSamDen?, statsSamU?, histogram?) > 

<!ELEMENT ptnName (#PCDATA) >  

<!ELEMENT histogram (colName, dataType, requestedStepCnt, actualStepCnt, samplingPct?, TuningFact?, statsOutRan?, statsHashLow?, statsHashHigh?, statsSamSt?, statsStepSt?, statsHtSt?, statsPHashSt?, statsHashSt?, statsNoHashSt?, steps*) >  

<!ELEMENT colName (#PCDATA) >
<!ELEMENT dataType (#PCDATA) >
<!ELEMENT requestedStepCnt (#PCDATA) >
<!ELEMENT actualStepCnt (#PCDATA) >  
<!ELEMENT samplingPct (#PCDATA) >  
<!ELEMENT TuningFact (#PCDATA) > 
<!ELEMENT statsOutRan (#PCDATA) >
<!ELEMENT statsHashLow (#PCDATA) >
<!ELEMENT statsHashHigh (#PCDATA) >
<!ELEMENT statsSamSt (#PCDATA) >
<!ELEMENT statsStepSt (#PCDATA) >
<!ELEMENT statsHtSt (#PCDATA) >
<!ELEMENT statsPHashSt (#PCDATA) >
<!ELEMENT statsHashSt (#PCDATA) >
<!ELEMENT statsNoHashSt (#PCDATA) >

<!ELEMENT steps (step, weight, equation, value) >

<!ELEMENT step (#PCDATA) >
<!ELEMENT weight (#PCDATA) >
<!ELEMENT equation (#PCDATA) >
<!ELEMENT value (#PCDATA) >  

<!ELEMENT noStatsCol (#PCDATA) >
See also:
  • Statistics Tables and Displaying Statistics with optdiag in Performance and Tuning Series: Improving Performance with Statistical Analysis; optdiag reference page in the Utility Guide.

  • optdiag in the Utility Guide

Permissions

Any user can execute sp_showoptstats. Permission checks do not differ based on the granular permissions settings.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect