Salesforce

How to get TEMP-TABLE table and index statistics?

« Go Back

Information

 
TitleHow to get TEMP-TABLE table and index statistics?
URL NameHow-to-get-TEMP-TABLE-table-and-index-statistics
Article Number000206189
EnvironmentProduct: OpenEdge
Version: 11.x, 12.x
OS: All Supported Platforms
Question/Problem Description

How to get the handle of the TableStatHistory and IndexStatHistory tables as referenced in https://docs.progress.com/bundle/openedge-abl-troubleshoot-applications-117/page/Collecting-temp-table-usage-statistics.html.
Is it possible to see Temp-table usage statistics from an ABL session?
Example code demonstrating how to Create, Access and Use the TableStatHistory and IndexStatHistory temp-tables.
How to get TableStatHistory and IndexStatHistory Temp-Tables?
 

Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
Normally the statistics for tables and indices (including TEMP-TABLEs and their indices) are available by reading the _TableStat and _IndexStat virtual system tables, while the tables are in use.  Unfortunately, for TEMP-TABLEs this information is destroyed once the TEMP-TABLEs (and their indexes) are deleted.

Therefore, if there is a need to collect the statistics for usage of TEMP-TABLEs for later analysis, there are two ways to accomplish this.
  1. Use the TTStats log entry type with LOG-MANAGER to log all of this information into a flat file.
    • This requires parsing the LOG-MANAGER output and massaging it into data structures in order to use it for analysis.
Examples: <PROEXE> -clientlog <logfilename> -logentrytypes TTStats[:<n>] | [-logginglevel <n>]
                  In PASOE: [AppServer.SessMgr.oepas1]
                                            agentLogEntryTypes=ASPlumbing,DB.Connects,4gltrace:3,TTStats:3
                   Classic AppServer and WebSpeed:
                                    [UBroker.AS.asbroker1]
                                          brkrLogEntryTypes=UBroker.Basic
                                          srvrLogEntryTypes=ASPlumbing,DB.Connects
For more information about using TTStats logging, see: Is there a LOG-ENTRY-TYPE to log TEMP-TABLE statistics?
  1. Use the _TableStatHist and _IndexStatHist tables to capture the historical usage information for the session.
NOTE: You cannot see statistics for any temp-table from within the same procedure/scope of TEMP-TABLEs you wish to track. 
            This information can ONLY be captured after the procedure that defines the TEMP-TABL(s) have finished executing (The TEMP-TABLE(s) must be out of scope).
  • There are a combination of steps you can use to capture statistical data about Table and Index usage in TEMP-TABLEs.  To enable this feature and access this data, you must follow the steps below:
  1. Start your ABL session with either or both of the the -tttablerangesize <n> -ttindexrangesize <n> parameters.  For instance, if you do not want to track index usage statistics in a temp-table you can omit the -ttindexrangesize <n> parameter.
For example: proenv>prowin -tttablerangesize 100 -ttindexrangesize 100
 
Note: Nothing will be captured if no range is defined for the resource (tables/indexes) you wish to capture using these parameters.
  1. Before running the code you wish to track, enable the Progress.Database.TempTableInfo:ArchiveTableStatistics and/or Progress.Database.TempTableInfo:ArchiveIndexStatistics properties.
Example:
/* enableTTHistory.p */
USING Progress.Database.*.

/* Enable the archival of Table and Index statistics
   using the TempTableInfo class properties.  
   
   Note: -tttablerangesize and/or -ttindexrangesize must 
         have a value greater than 0 for this to be effective. */
TempTableInfo:ArchiveTableStatistics = TRUE.
TempTableInfo:ArchiveIndexStatistics = TRUE.
  1. Run code you wish to track to completion.
/* applicationCode.p */
DEFINE TEMP-TABLE ttTest NO-UNDO
    FIELD f1 AS INT
    FIELD f2 AS CHAR
    INDEX idx1 IS PRIMARY UNIQUE f1.
    
DEFINE VARIABLE iCount    AS INTEGER     NO-UNDO.

DO iCount = 1 TO 10000: 
    CREATE ttTest. 
    ASSIGN ttTest.f1 = iCount 
           ttTest.f2 = STRING(iCount). 
END. 

DO iCount = 1 TO 10000 BY 3: 
    FIND ttTest WHERE ttTest.f1 EQ iCount NO-ERROR. 
    DELETE ttTest. 
END. 
  1. Read, View and/or Archive the data to XML or JSON:
/* queryTTUsageHistory.p */
USING Progress.Database.*.

/* Define handle variables to hold the TempTable and Index info */
DEFINE VARIABLE hTTInfo     AS HANDLE      NO-UNDO.
DEFINE VARIABLE hIdxInfo    AS HANDLE      NO-UNDO.

DEFINE VARIABLE hTTBuff     AS HANDLE      NO-UNDO.
DEFINE VARIABLE hIdxBuff    AS HANDLE      NO-UNDO.
DEFINE VARIABLE hTTQuery    AS HANDLE      NO-UNDO.
DEFINE VARIABLE hIdxQuery   AS HANDLE      NO-UNDO.

DEFINE VARIABLE cOutputFile AS CHARACTER   NO-UNDO 
    INITIAL "tempTableStats_&1_&2_&3.".

DEFINE BROWSE brTT  WITH SIZE 75 BY 10.
DEFINE BROWSE brIdx WITH SIZE 75 BY 10.

DEFINE FRAME fStats brTT SKIP(1) brIdx.

/* Use GetTableStatHistoryHandle() and GetIndexStatHistoryHandle() 
   methods to get the handles of the associated temp-tables. */
ASSIGN hTTInfo  = TempTableInfo:GetTableStatHistoryHandle()
       hTTBuff  = hTTInfo:DEFAULT-BUFFER-HANDLE
       hIdxInfo = TempTableInfo:GetIndexStatHistoryHandle()
       hIdxBuff = hIdxInfo:DEFAULT-BUFFER-HANDLE.

/* Add a timestamp to the output filename */
cOutputFile = SUBSTITUTE(cOutputFile,"~&1",
                         REPLACE(STRING(TODAY,"99/99/9999"),"/",""),
                         REPLACE(REPLACE(STRING(TIME,"HH:MM:SS AM"),":","")," ","")).

/* Demonstrate writing out XML with the Table and Index history */
hTTInfo:WRITE-XML("FILE",SUBSTITUTE(cOutputFile,"table") + "xml").
hIdxInfo:WRITE-XML("FILE",SUBSTITUTE(cOutputFile,"index") + "xml").

/* Demonstrate writing out JSON with the Table and Index history */
hTTInfo:WRITE-JSON("FILE",SUBSTITUTE(cOutputFile,"table") + "json").
hIdxInfo:WRITE-JSON("FILE",SUBSTITUTE(cOutputFile,"index") + "json").

/* Demonstrate accessing the data using BROWSE widgets */
CREATE QUERY hTTQuery.
hTTQuery:SET-BUFFERS(hTTBuff).
BROWSE brTT:QUERY = hTTQuery.

ASSIGN BROWSE brTT:SENSITIVE  = FALSE
       BROWSE brTT:EXPANDABLE = FALSE.

BROWSE brTT:ADD-COLUMNS-FROM(hTTBuff).

ASSIGN BROWSE brTT:SENSITIVE  = TRUE
       BROWSE brTT:EXPANDABLE = TRUE.
       
CREATE QUERY hIdxQuery.
hIdxQuery:SET-BUFFERS(hIdxBuff).
BROWSE brIdx:QUERY = hIdxQuery.

ASSIGN BROWSE brIdx:SENSITIVE  = FALSE
       BROWSE brIdx:EXPANDABLE = FALSE.

BROWSE brIdx:ADD-COLUMNS-FROM(hIdxBuff).

ASSIGN BROWSE brIdx:SENSITIVE  = TRUE
       BROWSE brIdx:EXPANDABLE = TRUE.

hTTQuery:QUERY-PREPARE("FOR EACH " + hTTBuff:NAME).
hTTQuery:QUERY-OPEN().

hIdxQuery:QUERY-PREPARE("FOR EACH " + hIdxBuff:NAME).
hIdxQuery:QUERY-OPEN().

ENABLE ALL WITH FRAME fStats.
WAIT-FOR CLOSE OF THIS-PROCEDURE.

FINALLY:
    /* Clean up */
    IF VALID-HANDLE(hTTQuery) AND
       hTTQuery:IS-OPEN THEN
        hTTQuery:QUERY-CLOSE() NO-ERROR.
        
    DELETE OBJECT hTTQuery NO-ERROR.
    
    IF VALID-HANDLE(hIdxQuery) AND
       hIdxQuery:IS-OPEN THEN
        hIdxQuery:QUERY-CLOSE() NO-ERROR.
        
    DELETE OBJECT hIdxQuery NO-ERROR.
END FINALLY.
The above program demonstrates writing out XML and JSON as well as displaying the history results in BROWSE widgets.
Workaround
Notes
References to Other Documentation:
Progress Article(s):
Is there a LOG-ENTRY-TYPE to log TEMP-TABLE statistics?
 
Keyword Phrase
Last Modified Date11/3/2021 1:51 PM

Powered by