ns::stats::SQLiteHistory method historyStorage (protected)
<instance of ns::stats::SQLiteHistory> historyStorage db config
Metadata only: no sample decompression. Allocated bytes include free SQLite pages; used bytes exclude those pages. The configured budget also reserves journal headroom, so report the effective database cap.
- Parameters:
- db (required)
- config (required)
- Testcases:
- No testcase defined.
Source code: set bounds [lindex [:sql $db {SELECT count(*) AS n,coalesce(min(at),0) AS first,coalesce(max(at),0) AS last FROM ns_stats_samples}] 0] set first [dict get $bounds first] set last [dict get $bounds last] set pageSize [:scalar $db {PRAGMA page_size}] set pageCount [:scalar $db {PRAGMA page_count}] set freePages [:scalar $db {PRAGMA freelist_count}] set used [expr {($pageCount-$freePages)*$pageSize}] set span [expr {($last-$first)/1000000.0}] return [dict create retainedFrom [expr {$first>0 ? $first/1000000.0 : ""}] retainedTo [expr {$last>0 ? $last/1000000.0 : ""}] retainedSeconds $span sampleCount [dict get $bounds n] pageSize $pageSize allocatedBytes [expr {$pageCount*$pageSize}] usedBytes $used freeBytes [expr {$freePages*$pageSize}] databaseLimitBytes [expr {[:scalar $db {PRAGMA max_page_count}]*$pageSize}] maxBytes [dict get $config maxBytes] bytesPerSample [expr {[dict get $bounds n]>0 ? double($used)/[dict get $bounds n] : ""}] bytesPerSecond [expr {$span>0 ? $used/$span : ""}]]XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)