SQLite

Check-in [d82cffab6a]
Login

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

Overview
Comment:Changes to the analyzer script to make it work with zipvfs databases.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d82cffab6acafcf9d91fea4ac47cad73f6f09775
User & Date: dan 2011-09-26 19:32:47.615
Context
2011-09-27
13:40
Changes to sqlite3_analyzer to try to avoid integer overflow problems when linking against older versions of TCL. (check-in: 8c846311a0 user: drh tags: trunk)
2011-09-26
19:32
Changes to the analyzer script to make it work with zipvfs databases. (check-in: d82cffab6a user: dan tags: trunk)
2011-09-25
17:49
If an open as read/write fails, do not try to reopen as read-only if in exclusive access mode. (check-in: 263c5fb280 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to tool/spaceanal.tcl.
30
31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
}

# Open the database
#
sqlite3 db $file_to_analyze
register_dbstat_vtab db

set pageSize [db one {PRAGMA page_size}]
db eval {SELECT count(*) FROM sqlite_master}


# In-memory database for collecting statistics. This script loops through
# the tables and indices in the database being analyzed, adding a row for each
# to an in-memory database (for which the schema is shown below). It then
# queries the in-memory db to produce the space-analysis report.
#
sqlite3 mem :memory:







<

>







30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45
}

# Open the database
#
sqlite3 db $file_to_analyze
register_dbstat_vtab db


db eval {SELECT count(*) FROM sqlite_master}
set pageSize [db one {PRAGMA page_size}]

# In-memory database for collecting statistics. This script loops through
# the tables and indices in the database being analyzed, adding a row for each
# to an in-memory database (for which the schema is shown below). It then
# queries the in-memory db to produce the space-analysis report.
#
sqlite3 mem :memory:
353
354
355
356
357
358
359




360
361



362
363
364
365
366
367
368
# nindex:        Number of indices in the db.
# nautoindex:    Number of indices created automatically.
# nmanindex:     Number of indices created manually.
# user_payload:  Number of bytes of payload in table btrees 
#                (not including sqlite_master)
# user_percent:  $user_payload as a percentage of total file size.





set file_bytes  [file size $file_to_analyze]
set file_pgcnt  [expr {$file_bytes/$pageSize}]




set av_pgcnt    [autovacuum_overhead $file_pgcnt $pageSize]
set av_percent  [percent $av_pgcnt $file_pgcnt]

set sql {SELECT sum(leaf_pages+int_pages+ovfl_pages) FROM space_used}
set inuse_pgcnt   [expr int([mem eval $sql])]
set inuse_percent [percent $inuse_pgcnt $file_pgcnt]







>
>
>
>
|
|
>
>
>







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# nindex:        Number of indices in the db.
# nautoindex:    Number of indices created automatically.
# nmanindex:     Number of indices created manually.
# user_payload:  Number of bytes of payload in table btrees 
#                (not including sqlite_master)
# user_percent:  $user_payload as a percentage of total file size.

### The following, setting $file_bytes based on the actual size of the file
### on disk, causes this tool to choke on zipvfs databases. So set it based
### on the return of [PRAGMA page_count] instead.
if 0 {
  set file_bytes  [file size $file_to_analyze]
  set file_pgcnt  [expr {$file_bytes/$pageSize}]
}
set file_pgcnt  [db one {PRAGMA page_count}]
set file_bytes  [expr $file_pgcnt * $pageSize]

set av_pgcnt    [autovacuum_overhead $file_pgcnt $pageSize]
set av_percent  [percent $av_pgcnt $file_pgcnt]

set sql {SELECT sum(leaf_pages+int_pages+ovfl_pages) FROM space_used}
set inuse_pgcnt   [expr int([mem eval $sql])]
set inuse_percent [percent $inuse_pgcnt $file_pgcnt]