如何知道Progress-4GL中程序访问的记录数量



我想知道一个正在运行的程序正在访问多少记录。我找到了VST _TableStat,但它没有按程序分组记录的数量。

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.

这段代码显示了表和有多少条记录被访问,但是我想知道是哪个程序在访问表。

有办法知道这个吗?还是有带PID的_TableStat之类的表?

p。:我正在使用进度10.2B.

提前感谢,Rubinho桑托斯

Progress是什么版本?

在10.1C左右引入了_UserTableStat。

在_connect VST中也有"客户端语句缓存"字段。如果为会话启用了适当的位,则保存堆栈跟踪,以便您可以确定会话正在执行的行以及它是如何到达那里的。

他们可以让你得到你所需要的。

顺便说一句:ProTop显示了这些数据的大部分—http://dbappraise.com/protop.html

如果您需要细粒度的程序统计信息,您可能还需要查看一些"日志入口类型"的特性,如4gltrace和QryInfo。

它与表_UserTableStat一起工作,正如我所期望的:

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.

感谢Tom Bascom的帮助!

上面的代码对于_connect和_UserTableStat之间的连接有一个问题:

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

你必须用这个代替:

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

接下来,下面的代码段给出了一个按_UserTableStat-read降序排序的列表:

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.
    

相关内容

  • 没有找到相关文章

最新更新