/ Check-in [82aed271]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Additional fixes to the new fragmentation feature of sqlite3_analyzer. (CVS 3635)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:82aed271a4a69e3dad6013b83cc7d492b7fed164
User & Date: drh 2007-02-13 01:38:31
Context
2007-02-13
01:41
Explanation of the "fragmentation" line is added to the help message at the end of the output of sqlite3_analyzer. (CVS 3636) check-in: 31e5073c user: drh tags: trunk
01:38
Additional fixes to the new fragmentation feature of sqlite3_analyzer. (CVS 3635) check-in: 82aed271 user: drh tags: trunk
2007-02-10
19:22
Changes to support fragmentation analysis in sqlite3_analyzer. (CVS 3634) check-in: bd6bc3b8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/spaceanal.tcl.

   227    227           set pglist "$ci(page_no) $pglist"
   228    228         }
   229    229       }
   230    230   
   231    231       # Check the page list for fragmentation
   232    232       #
   233    233       foreach pg $pglist {
   234         -      if {($pg<$prev_pgno || $pg>$prev_pgno+$MAXGAP) && $prev_pgno>0} {
          234  +      if {$pg!=$prev_pgno+1 && $prev_pgno>0} {
   235    235           incr gap_cnt
   236    236         }
   237    237         set prev_pgno $pg
   238    238       }
   239    239     }
   240    240     btree_close_cursor $csr
   241    241   
................................................................................
   348    348       # the page-related statistics $leaf_pages and $unused_leaf.
   349    349       #
   350    350       if {![info exists seen($ci(page_no))]} {
   351    351         set seen($ci(page_no)) 1
   352    352         incr leaf_pages
   353    353         incr unused_leaf $ci(page_freebytes)
   354    354         set pg $ci(page_no)
   355         -      if {$prev_pgno>0 && ($prev_pgno<$pg-$MAXGAP || $prev_pgno>$pg)} {
          355  +      if {$prev_pgno>0 && $pg!=$prev_pgno+1} {
   356    356           incr gap_cnt
   357    357         }
   358    358         set prev_pgno $ci(page_no)
   359    359       }
   360    360     }
   361    361     btree_close_cursor $csr
   362    362   
................................................................................
   480    480     set total_pages [expr {$leaf_pages+$int_pages+$ovfl_pages}]
   481    481     set total_pages_percent [percent $total_pages $file_pgcnt]
   482    482     set storage [expr {$total_pages*$pageSize}]
   483    483     set payload_percent [percent $payload $storage {of storage consumed}]
   484    484     set total_unused [expr {$ovfl_unused+$int_unused+$leaf_unused}]
   485    485     set avg_payload [divide $payload $nleaf]
   486    486     set avg_unused [divide $total_unused $nleaf]
   487         -  set fragmentation [percent $gap_cnt $total_pages {fragmentation}]
   488    487     if {$int_pages>0} {
   489    488       # TODO: Is this formula correct?
   490    489       set nTab [mem eval "
   491    490         SELECT count(*) FROM (
   492    491             SELECT DISTINCT tblname FROM space_used WHERE $where AND is_index=0
   493    492         )
   494    493       "]
................................................................................
   508    507     statline {Bytes of payload} $payload $payload_percent
   509    508     statline {Average payload per entry} $avg_payload
   510    509     statline {Average unused bytes per entry} $avg_unused
   511    510     if {[info exists avg_fanout]} {
   512    511       statline {Average fanout} $avg_fanout
   513    512     }
   514    513     if {$total_pages>1} {
          514  +    set fragmentation [percent $gap_cnt [expr {$total_pages-1}] {fragmentation}]
   515    515       statline {Fragmentation} $fragmentation
   516    516     }
   517    517     statline {Maximum payload per entry} $mx_payload
   518    518     statline {Entries that use overflow} $ovfl_cnt $ovfl_cnt_percent
   519    519     if {$int_pages>0} {
   520    520       statline {Index pages used} $int_pages
   521    521     }