I am not sure whether I completely understand your requirement ...
There is no way to find out the number of BI clusters used by a single transaction. You can only find out the actual number of clusters for _ALL_ transactions. The size of the BI on disk won't tell you the actual utilization. The actual utilization is based on the number of BI clusters in use.
To find out the actual number of BI clusters in use you need to know the lowest and the highest cluster numbers used by any transaction. The lowest number is rather easy, but the highes is rather tricky - you need to start a transaction yourself ...
This is just a code snippet to get the lowest and highest cluster number:
Code:
txn-blk:
do for SessionBuffer transaction on error undo, throw:
/* Update something */
create SessionBuffer.
assign SessionBuffer.sessionIdSymbol = guid ( generate-uuid ).
/* Fetch the transaction associated with my connection - the _Trans-Counter will give us the newest BI cluster */
for first _MyConnection no-lock,
first _Trans no-lock where _Trans._Trans-UsrNum = _MyConnection._MyConn-UserId:
assign newestBeforeImageCluster = _Trans._Trans-Counter
oldestBeforeImageCluster = newestBeforeImageCluster.
end.
/* The smallest value in the _Trans-Counter will give us the oldest BI cluster in use */
for each _Trans no-lock where _Trans._Trans-State = 'ACTIVE' and _Trans._Trans-Counter > 0:
if _Trans._Trans-Counter < oldestBeforeImageCluster then
assign oldestBeforeImageCluster = _Trans._Trans-Counter.
end.
undo txn-blk, leave txn-blk.
end.
From there you can go on and compare the number of used clusters with your maximum BI size to get the utilization.
Heavy Regards, RealHeavyDude.