1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Enhance the sqlite3_analyzer.exe utility so that it computes and shows the

number of bytes of metadata on btree pages and per table and index entry.

FossilOrigin-Name: 43ad41efa9e1fdd79a9804197a227491236495f14ed56c656224d6ce181703c1
This commit is contained in:
drh
2017-06-15 00:52:03 +00:00
parent 2ebf8f474e
commit c74d962a1f
3 changed files with 24 additions and 8 deletions

View File

@ -424,6 +424,7 @@ proc subreport {title where showFrag} {
# avg_payload: Average payload per btree entry.
# avg_fanout: Average fanout for internal pages.
# avg_unused: Average unused bytes per btree entry.
# avg_meta: Average metadata overhead per entry.
# ovfl_cnt_percent: Percentage of btree entries that use overflow pages.
#
set total_pages [expr {$leaf_pages+$int_pages+$ovfl_pages}]
@ -433,6 +434,10 @@ proc subreport {title where showFrag} {
set total_unused [expr {$ovfl_unused+$int_unused+$leaf_unused}]
set avg_payload [divide $payload $nentry]
set avg_unused [divide $total_unused $nentry]
set total_meta [expr {$storage - $payload - $total_unused}]
set total_meta [expr {$total_meta + 4*($ovfl_pages - $ovfl_cnt)}]
set meta_percent [percent $total_meta $storage {of metadata}]
set avg_meta [divide $total_meta $nentry]
if {$int_pages>0} {
# TODO: Is this formula correct?
set nTab [mem eval "
@ -460,9 +465,11 @@ proc subreport {title where showFrag} {
statline {Bytes used after compression} $compressed_size $pct
}
statline {Bytes of payload} $payload $payload_percent
statline {Bytes of metadata} $total_meta $meta_percent
if {$cnt==1} {statline {B-tree depth} $depth}
statline {Average payload per entry} $avg_payload
statline {Average unused bytes per entry} $avg_unused
statline {Average metadata per entry} $avg_meta
if {[info exists avg_fanout]} {
statline {Average fanout} $avg_fanout
}
@ -757,6 +764,15 @@ Bytes of payload
at the right is the bytes of payload divided by the bytes of storage
consumed.
Bytes of metadata
The amount of formatting and structural information stored on for the
table or index. Metadata includes the btree page header, the cell pointer
array, the size field for each cell, the left child pointer or non-leaf
cells, the overflow pointers for overflow cells, and the rowid value for
rowid table cells. In other words, metadata is everything that is not
unused space and that is not content.
Average payload per entry
The average amount of payload on each entry. This is just the bytes of