Kbase P5590: 4GL. How to know how many records for each table have been accessed?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/17/2004 |
|
Status: Unverified
GOAL:
4GL. How to know how many records for each table have been accessed?
GOAL:
How to know how many records for each table have been read?
FACT(s) (Environment):
Progress V8.x
Progress V9.x
FIX:
This example will show you how many records have been read in each table within a DB.
If you want to use this code with V8 you will have to enable the -tablebase/-tablelimit Startup Parameters.
In Version 9 -basetable/-tablerangesize are enabled by default for 50 tables, you will need to specify values for more if more tables are involved.
In way to run you need to run in multi-user mode from a separate session.
/* Author: pmartine EMEA-ETSC
Date: 07/31/2002
Description: This procedure access the VST and returns
the amount of records reads in the DB
*/
DEFINE VAR wWin AS WIDGET-HANDLE NO-UNDO.
def var TotalOfRecordRead as int
label "Total of Reads" VIEW-AS FILL-IN.
def var i as int.
def var LastTimeResults as dec format ">>>,>>9.99"
label "Duration" VIEW-AS FILL-IN.
def temp-table TReads
field table-name as char format "x(20)"
field table-id as int
field reads as int
index i1 is unique primary table-id.
def temp-table high-reads
field table-name as char format "x(20)"
field reads as int
index i1 is unique table-name
index i2 is primary reads descending.
DEFINE QUERY QReads FOR high-reads SCROLLING.
DEFINE BROWSE BROWSE-2
QUERY QReads NO-LOCK DISPLAY
table-name
reads
WITH NO-ROW-MARKERS SEPARATORS SIZE 60 BY 10 EXPANDABLE.
DEFINE BUTTON BUTTON-1
LABEL "Refresh"
SIZE 15 BY 1.14 TOOLTIP "~"Refresh Values~""
BGCOLOR 8 .
DEFINE FRAME fMain
TotalOfRecordRead skip
LastTimeResults SKIP
browse-2 SKIP
button-1
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1
SIZE 70 BY 20.
CREATE WINDOW wWin ASSIGN
HIDDEN = YES
TITLE = "Records Reads"
HEIGHT = 23
WIDTH = 65
MAX-HEIGHT = 20
MAX-WIDTH = 80
VIRTUAL-HEIGHT = 21
VIRTUAL-WIDTH = 65
RESIZE = no
SCROLL-BARS = no
STATUS-AREA = no
BGCOLOR = ?
FGCOLOR = ?
THREE.-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.
ON WINDOW-CLOSE OF wWin
DO:
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
ON "CHOOSE":U OF button-1
DO:
TotalOfRecordRead = 0.
FOR EACH TReads:
DELETE TReads.
END.
FOR EACH high-reads:
DELETE high-reads.
END.
for each _file where _file-num > 0 and _file-num < 32767 no-lock.
create TReads.
assign TReads.table-name = _file-name
TReads.table-id = _file-num
TReads.reads = 0.
create high-reads.
assign high-reads.table-name = _file-name.
end.
LastTimeResults = etime(yes).
for each high-reads:
high-reads.reads = 0.
end.
for each _tablestat where _tablestat-id > 0 and _tablestat-id < 32767 no-lock.
find TReads where TReads.table-id = _tablestat._tablestat-id no-error.
if not available TReads then next.
if TReads.reads <> _tablestat._tablestat-read then do:
find high-reads where TReads.table-name = high-reads.table-name.
high-reads.reads = _tablestat-read - TReads.reads.
TReads.reads = _tablestat-read.
end. /* if reads found */
end. /* for each _tablestat */
assign i = 0
TotalOfRecordRead = 0.
display TotalOfRecordRead WITH frame fMain.
for each high-reads:
assign i = i + 1
TotalOfRecordRead = TotalOfRecordRead + high-reads.reads.
end.
LastTimeResults = etime(yes) / 1000.
display TotalOfRecordRead LastTimeResults with frame fMain.
OPEN QUERY QReads FOR EACH HIGH-READS NO-LOCK.
RETURN.
END.
ENABLE browse-2
button-1 WITH FRAME fMain.
VIEW FRAME fMain.
WAIT-FOR CLOSE OF THIS-PROCEDURE..