Question

I'm trying to know how many records a running program is accessing. I found the VST _TableStat, but it doesn't group the number of records by program.

FOR  EACH _TableStat NO-LOCK
    WHERE _TableStat._TableStat-Create > 0
       OR _TableStat._TableStat-Delete > 0
       OR _TableStat._TableStat-Read   > 0
       OR _TableStat._TableStat-Update > 0,
    FIRST _File NO-LOCK
    WHERE _File._File-Number = _TableStat._TableStat-Id:

    DISPLAY
      /*_File._File-Name*/
        _TableStat-Create
        _TableStat._TableStat-Delete
        _TableStat._TableStat-Read  
        _TableStat._TableStat-Update
        WITH SIDE-LABELS 1 COLUMN 1 DOWN.
END.

This code shows me the tables and how many records are being accessed, but I want to know the program wich is accessing the table.

Is there a way to know this? Or is there a table like _TableStat with a PID or something like that?

Ps.: I'm using Progress 10.2B.

Thanks in advance, Rubinho Santos

Was it helpful?

Solution

What version of Progress?

Somewhere around 10.1C _UserTableStat was introduced. It has table stats by user.

There are also the "client statement cache" fields in the _connect VST. If the proper bits are enabled for a session then a stack trace is saved so that you can determine what line a session is executing and how it got there.

Between them they may allow you to get what you need.

BTW: ProTop shows you much of this data -- http://dbappraise.com/protop.html

You might also want to look at some of the "log-entry-types" features like 4gltrace and QryInfo if you need fine grained program by program stats.

OTHER TIPS

It works with the table _UserTableStat as I was expecting:

FOR EACH _UserTableStat NO-LOCK
   WHERE _UserTableStat._UserTableStat-Read   > 0
      OR _UserTableStat._UserTableStat-Create > 0
      OR _UserTableStat._UserTableStat-Update > 0
      OR _UserTableStat._UserTableStat-Delete > 0,
   FIRST _File NO-LOCK
   WHERE _File._File-Number = _UserTableStat._UserTableStat-Num,
   FIRST _Connect NO-LOCK
   WHERE _Connect._Connect-Id = _UserTableStat._UserTableStat-Conn:

    DISPLAY
        _Connect._Connect-IPAddress          
        _Connect._Connect-Name               
        _Connect._Connect-Pid                
        _File._File-Name                     
        _UserTableStat._UserTableStat-Read   
        _UserTableStat._UserTableStat-Create 
        _UserTableStat._UserTableStat-Update 
        _UserTableStat._UserTableStat-Delete 
    WITH SIDE-LABELS THREE-D 1 COLUMN 1 DOWN.

END.

Thanks Tom Bascom for the help!

The above code had a problem with this join between _connect and _UserTableStat:

WHERE _Connect._Connect-Id = _UserTableStat._UserTableStat-Conn

You have to use this instead:

WHERE _Connect._Connect-Usr = _UserTableStat._UserTableStat-Conn
  hint: _Connect-Usr = _Connect-Id + 1

Next, the following piece of code gives a list sorted on _UserTableStat-read descending:

DEFAULT-WINDOW:WIDTH-CHARS = 240.

DEFINE VARIABLE dmon           AS DATETIME NO-UNDO.
DEFINE VARIABLE dstart         AS DATETIME NO-UNDO.
DEFINE VARIABLE iusertablestat AS INTEGER  NO-UNDO.
DEFINE VARIABLE lfirstview     AS LOGICAL  INITIAL TRUE NO-UNDO.

DEFINE TEMP-TABLE ttuts LIKE _UserTableStat
    FIELD _Connect-Type       AS CHARACTER INITIAL ?
    FIELD _Connect-Name       AS CHARACTER INITIAL ? FORMAT "X(15)"
    FIELD _Connect-Time       AS CHARACTER INITIAL ? FORMAT "X(25)"
    FIELD _Connect-ClientType AS CHARACTER INITIAL ?
    INDEX _UserTableStat-read   _UserTableStat-read
    INDEX _UserTableStat-update _UserTableStat-update
    INDEX _UserTableStat-create _UserTableStat-create
    INDEX _UserTableStat-delete _UserTableStat-delete.
    
dstart = NOW.
dmon = NOW.
DEFAULT-WINDOW:TITLE = SUBSTITUTE("starting scan of _UserTableStat at &1", dstart).
FOR EACH _UserTableStat NO-LOCK: 
    iusertablestat = iusertablestat + 1.

    IF     iusertablestat MODULO 10000 = 0 
        OR INTERVAL(NOW, dmon, "milliseconds") > 1000 THEN
    DO:
        dmon = NOW.
        IF lfirstview THEN
        DO:
            DISPLAY "scanning in process" WITH FRAME fviewit.
            lfirstview = FALSE.
        END.
        DEFAULT-WINDOW:TITLE = SUBSTITUTE("&1 - Scanning since &2 ms - &3 _UserTableStat records (started at &4)"
            , NOW, INTERVAL(NOW, dstart, "milliseconds"), iusertablestat, dstart).
         
        DEFAULT-WINDOW:TITLE = SUBSTITUTE("starting scan of _UserTableStat at &1  scanned &2 records", dstart, iusertablestat).
        PROCESS EVENTS.
    END.

    /* if you are interested in updates or delte, then adapath this next line */
    IF _UserTableStat._UserTableStat-read = 0 
        THEN NEXT.
    
    IF _UserTableStat._UserTableStat-Conn <> ?
        THEN FIND _Connect NO-LOCK WHERE _Connect._Connect-Usr = _UserTableStat._UserTableStat-Conn NO-ERROR. /* beware: you may use _UserTableStat-id + 1 too but do not miss the + 1*/
    ELSE RELEASE _Connect.
    
    CREATE ttuts.
    BUFFER-COPY _UserTableStat TO ttuts.
    IF AVAIL _Connect
        THEN BUFFER-COPY _Connect TO ttuts.
END.


DEFAULT-WINDOW:TITLE = SUBSTITUTE("&1 - Scan completed in &2 ms through &3 _UserTableStat records (started at &4)"
    , NOW, INTERVAL(NOW, dstart, "milliseconds"), iusertablestat, dstart).

FOR EACH ttuts 
    , FIRST _File NO-LOCK WHERE _File._File-Number = ttuts._UserTableStat-Num
    BY ttuts._UserTableStat-read DESCENDING: 
    DISPLAY 
        ttuts._UserTableStat-Num
        _File._File-Name
        ttuts._Connect-Name 
        ttuts._UserTableStat-Conn  /* = _Connect._Connect-Usr */
        ttuts._Connect-Type  
        ttuts._Connect-Time  
        ttuts._Connect-ClientType 
        ttuts._UserTableStat-read   FORMAT ">>>,>>>,>>>,>>>,>>9"
        ttuts._UserTableStat-update FORMAT ">>>,>>>,>>>,>>>,>>9"
        ttuts._UserTableStat-create FORMAT ">>>,>>>,>>>,>>>,>>9"
        ttuts._UserTableStat-delete FORMAT ">>>,>>>,>>>,>>>,>>9"
        WITH WIDTH 240 FRAME fttuts 17 DOWN.
END.
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top