From: drh Date: Sat, 28 Sep 2013 12:40:55 +0000 (+0000) Subject: Updates to the sqlite3_analyzer utility: Change the names of some labels, X-Git-Tag: version-3.8.1~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f312ee65f7692156259d849dc6db2ae74ad5d76;p=thirdparty%2Fsqlite.git Updates to the sqlite3_analyzer utility: Change the names of some labels, especially change "Fragmentation" to "Non-sequential pages". Revise the computation of non-sequential pages so that it ignores itercalated non-leaf pages (overflow and index pages). FossilOrigin-Name: 3e5c7771fa91d8ae1e495432329b87af87b1ebc6 --- diff --git a/manifest b/manifest index 3c02417f64..d7efafc1a0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Obtain\sthe\srequired\sshared-cache\swrite-lock\swhen\sexecuting\s"DELETE\sFROM\stbl"\sstatements.\sFix\sfor\s[1e1321ee98]. -D 2013-09-26T15:21:16.149 +C Updates\sto\sthe\ssqlite3_analyzer\sutility:\s\sChange\sthe\snames\sof\ssome\slabels,\nespecially\schange\s"Fragmentation"\sto\s"Non-sequential\spages".\s\sRevise\sthe\ncomputation\sof\snon-sequential\spages\sso\sthat\sit\signores\sitercalated\snon-leaf\npages\s(overflow\sand\sindex\spages). +D 2013-09-28T12:40:55.568 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1098,7 +1098,7 @@ F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b -F tool/spaceanal.tcl f87fc8e459e3e42255b52987fe0dda3f8a8c513d +F tool/spaceanal.tcl d8c11da184b1a13d0456d786e70b3867e141b74a F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -1114,7 +1114,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 1e1321ee985370c2b7e5bd64286bb4d7704b5a30 -R a0865cc0b0415ad5c165b04432fdea63 -U dan -Z 44cdc40bea63a1811eda504072199b21 +P 1f8f4fdf3ff2b8de27e167a44a19b0f479f5ee1a +R c3d18dfbcf3bb3edd932a7a2596858df +U drh +Z c9cd9d7c9e74e96fef1c3e1fc50d6050 diff --git a/manifest.uuid b/manifest.uuid index 9f53649264..044d95e6ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f8f4fdf3ff2b8de27e167a44a19b0f479f5ee1a \ No newline at end of file +3e5c7771fa91d8ae1e495432329b87af87b1ebc6 \ No newline at end of file diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl index e2f23fe4bf..9cb62983ef 100644 --- a/tool/spaceanal.tcl +++ b/tool/spaceanal.tcl @@ -199,15 +199,17 @@ foreach {name tblname} [concat sqlite_master sqlite_master [db eval $sql]] { # is. # set gap_cnt 0 - set pglist [db eval { - SELECT pageno FROM temp.dbstat WHERE name = $name ORDER BY rowid - }] - set prev [lindex $pglist 0] - foreach pgno [lrange $pglist 1 end] { - if {$pgno != $prev+1} {incr gap_cnt} - set prev $pgno + set prev 0 + db eval { + SELECT pageno, pagetype FROM temp.dbstat + WHERE name=$name + ORDER BY pageno + } { + if {$prev>0 && $pagetype=="leaf" && $pageno!=$prev+1} { + incr gap_cnt + } + set prev $pageno } - mem eval { INSERT INTO space_used VALUES( $name, @@ -298,7 +300,7 @@ proc divide {num denom} { # Generate a subreport that covers some subset of the database. # the $where clause determines which subset to analyze. # -proc subreport {title where} { +proc subreport {title where showFrag} { global pageSize file_pgcnt compressOverhead # Query the in-memory database for the sum of various statistics @@ -384,9 +386,9 @@ proc subreport {title where} { if {[info exists avg_fanout]} { statline {Average fanout} $avg_fanout } - if {$total_pages>1} { - set fragmentation [percent $gap_cnt [expr {$total_pages-1}] {fragmentation}] - statline {Fragmentation} $fragmentation + if {$showFrag && $total_pages>1} { + set fragmentation [percent $gap_cnt [expr {$total_pages-1}]] + statline {Non-sequential pages} $gap_cnt $fragmentation } statline {Maximum payload per entry} $mx_payload statline {Entries that use overflow} $ovfl_cnt $ovfl_cnt_percent @@ -509,8 +511,8 @@ statline {Pages on the freelist (calculated)} $free_pgcnt $free_percent statline {Pages of auto-vacuum overhead} $av_pgcnt $av_percent statline {Number of tables in the database} $ntable statline {Number of indices} $nindex -statline {Number of named indices} $nmanindex -statline {Automatically generated indices} $nautoindex +statline {Number of defined indices} $nmanindex +statline {Number of implied indices} $nautoindex if {$isCompressed} { statline {Size of uncompressed content in bytes} $file_bytes set efficiency [percent $true_file_size $file_bytes] @@ -563,11 +565,11 @@ if {$isCompressed} { # Output subreports # if {$nindex>0} { - subreport {All tables and indices} 1 + subreport {All tables and indices} 1 0 } -subreport {All tables} {NOT is_index} +subreport {All tables} {NOT is_index} 0 if {$nindex>0} { - subreport {All indices} {is_index} + subreport {All indices} {is_index} 0 } foreach tbl [mem eval {SELECT name FROM space_used WHERE NOT is_index ORDER BY name}] { @@ -578,17 +580,17 @@ foreach tbl [mem eval {SELECT name FROM space_used WHERE NOT is_index set idxlist [mem eval "SELECT name FROM space_used WHERE tblname='$qn' AND is_index ORDER BY 1"] - subreport "Table $name and all its indices" "tblname='$qn'" - subreport "Table $name w/o any indices" "name='$qn'" + subreport "Table $name and all its indices" "tblname='$qn'" 0 + subreport "Table $name w/o any indices" "name='$qn'" 1 if {[llength $idxlist]>1} { - subreport "Indices of table $name" "tblname='$qn' AND is_index" + subreport "Indices of table $name" "tblname='$qn' AND is_index" 0 } foreach idx $idxlist { set qidx [quote $idx] - subreport "Index [string toupper $idx] of table $name" "name='$qidx'" + subreport "Index [string toupper $idx] of table $name" "name='$qidx'" 1 } } else { - subreport "Table $name" "name='$qn'" + subreport "Table $name" "name='$qn'" 1 } } @@ -633,11 +635,11 @@ Number of indices The total number of indices in the database. -Number of named indices +Number of defined indices The number of indices created using an explicit CREATE INDEX statement. -Automatically generated indices +Number of implied indices The number of indices used to implement PRIMARY KEY or UNIQUE constraints on tables. @@ -686,13 +688,16 @@ Average unused bytes per entry category on a per-entry basis. This is the number of unused bytes on all pages divided by the number of entries. -Fragmentation +Non-sequential pages - The percentage of pages in the table or index that are not - consecutive in the disk file. Many filesystems are optimized - for sequential file access so smaller fragmentation numbers - sometimes result in faster queries, especially for larger - database files that do not fit in the disk cache. + The number of pages in the table or index that are out of sequence. + Many filesystems are optimized for sequential file access so a small + number of non-sequential pages might result in faster queries, + especially for larger database files that do not fit in the disk cache. + Note that after running VACUUM, the root page of each table or index is + at the beginning of the database file and all other pages are in a + separate part of the database file, resulting in a single non- + sequential page. Maximum payload per entry