Kbase P119117: How to count the records read by each index on a table?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  7/13/2007 |
|
Status: Unverified
GOAL:
How to count the records read by each index on a table?
GOAL:
Does each index return the same number of results?
FIX:
The following code is provided as a *simple* example, that generates a code example: countrecs.p
The resulting "countrecs.p": writes the number of records returned by each index (except word indexes) defined for a table (defined in cFileName previously) to count.txt file for review.
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO. /* Table Name ? */
ASSIGN cFileName = "customer".
OUTPUT TO countrecs.p.
PUT UNFORMATTED
"DEFINE STREAM data2." SKIP
"OUTPUT STREAM data2 TO 'count.txt'." SKIP(1)
"DEFINE VARIABLE recNo AS INTEGER FORMAT 'ZZ,ZZZ,ZZZ'." SKIP(1).
FIND _file WHERE _File-name = cFileName.
FOR EACH _index OF _file WHERE _Wordidx <> 1:
PUT UNFORMATTED
"PAUSE 0." SKIP
"ASSIGN recNo = 0." SKIP
"FOR EACH " + _File-name + " USE-INDEX " + _Index-name + " NO-LOCK:" SKIP
" ASSIGN recNo = recNo + 1." SKIP
"END." SKIP
"EXPORT STREAM data2 '" _File-name " , " _Index-name " ' + STRING(recNo) FORMAT 'x(20)'. " SKIP(1).
END.
PUT "OUTPUT STREAM data2 CLOSE." SKIP.