Skip to content

Instantly share code, notes, and snippets.

@cverbiest
Last active August 29, 2015 14:22
Show Gist options
  • Save cverbiest/a30bfa8cb73d8d9e3081 to your computer and use it in GitHub Desktop.
Save cverbiest/a30bfa8cb73d8d9e3081 to your computer and use it in GitHub Desktop.
OpenEdge _IndexStat csv export
/*
Code to generate csv file from _IndexStat
Comment from George Potemkin
https://community.progress.com/community_groups/openedge_rdbms/f/18/p/17913/65295.aspx#65295
This program uses the _IndexStat-split and _IndexStat-blockdelete fields.
Due to a Progress bug the value of "blockdelete" field is always zero and the value in "split" field is incorrect.
The same is true for _UserIndexStat and for promon. They all read the correct bytes in shared memory.
It's the Progress clients who update a wrong counter when a block is deleted (freed) from index tree.
Namely they increase the "split" counter.
In other words the "split" field returns the sum of the splits and deletes.
My DbStatDump.p is trying to adjust the results as:
_IndexStat-blockdelete = _IndexStat-split * _IndexStat-delete / (_IndexStat-delete + _IndexStat-create).
_IndexStat-split = _IndexStat-split - _IndexStat-blockdelete.
It's not 100% accurate but it's better than the initial "lie".
I marked those fields as (bad) for now.
*/
&scoped file _IndexStat
&scoped delim ,
output to logfiles/indexstat.csv.
find _DbStatus.
export delimiter "{&delim}"
"_file-name"
"_Index-Name"
"_IndexStat-id"
"_IndexStat-read"
"_IndexStat-OsRead"
"_IndexStat-create"
"_IndexStat-split(bad)"
"_IndexStat-delete"
"_IndexStat-blockdelete(bad)"
"_TableStat-read"
"_TableStat-OsRead"
"_TableStat-create"
"_TableStat-update"
"_TableStat-delete"
_DbStatus-LastOpen.
for each {&file}
where _IndexStat-read + _IndexStat-create + _IndexStat-delete > 0 ,
first _index where _index._idx-num = {&file}._IndexStat-id,
first _file of _index,
first _TableStat where _tablestat._tablestat-id = _file._file-number
by _file-name by _IndexStat-read desc:
def var lIdxFields as char no-undo.
lIdxFields = "".
for each _index-field of _index, _field of _index-field:
lIdxFields = subst("&1 &2", lIdxFields, string(_Ascending, "+/-"), _field-name).
end.
export delimiter "{&delim}"
_file-name
_Index-Name
_IndexStat-id
_IndexStat-read
&if { pvers_ge.i 11.0 }
&then
_IndexStat-OsRead
&else
?
&endif
_IndexStat-create
_IndexStat-split
_IndexStat-delete
_IndexStat-blockdelete
_TableStat-read
&if { pvers_ge.i 11.0 }
&then
_TableStat-OsRead
&else
?
&endif
_TableStat-create
_TableStat-update
_TableStat-delete
lIdxFields
.
end.
/* if-proversion.gt, thanks to George Potemkin */
((DECIMAL(SUBSTRING(PROVERSION,1, INDEX(PROVERSION, ".") + 1)) GT
DECIMAL(SUBSTRING("{1}",1, INDEX("{1}.",".") + 1)))
OR (DECIMAL(SUBSTRING(PROVERSION, 1, INDEX(PROVERSION, ".") + 1)) EQ
DECIMAL(SUBSTRING("{1}", 1, INDEX("{1}.",".") + 1))
AND
SUBSTRING(PROVERSION, INDEX(PROVERSION, ".")) GE
SUBSTRING("{1}", INDEX("{1}.", "."))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment