2

我想知道一个正在运行的程序正在访问多少条记录。我找到了 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.

此代码向我显示了表以及正在访问多少记录,但我想知道正在访问表的程序。

有没有办法知道这一点?或者是否有像 _TableStat 这样的带有 PID 或类似的表?

Ps.:我正在使用 Progress 10.2B。

在此先感谢,鲁比尼奥桑托斯

4

3 回答 3

3

什么版本的进度?

大约在 10.1C 的某个地方引入了 _UserTableStat。它有用户的表格统计信息。

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

在它们之间,它们可以让你得到你需要的东西。

顺便说一句:ProTop 向您展示了大部分数据——http: //dbappraise.com/protop.html

如果您需要按程序统计的细粒度程序,您可能还想查看一些“日志条目类型”功能,例如 4gltrace 和 QryInfo。

于 2013-03-28T19:34:57.540 回答
1

正如我所期望的那样,它与表 _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.

感谢汤姆巴斯科姆的帮助!

于 2013-04-02T19:18:13.483 回答
0

上面的代码在 _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.
    
于 2020-09-16T14:01:20.940 回答