Sample Output
Santiago Gil edited this page Jan 8, 2018
·
1 revision
This is an example output obtained by running the script on a database with a single table and indices pointing to 4 of its columns.
It can be sourced directly into any SQL database engine for further analysis, since all but the last portion of the text is formatted as an SQL comment.
/** Disk-Space Utilization Report For ontime.db
Page size in bytes ............................................. 4096
Pages in the whole file (measured) .......................... 4208888
Pages in the whole file (calculated) ........................ 4208887
Pages that store data ....................................... 4208887 100.00%
Pages on the freelist (per header) ................................ 0
Pages on the freelist (calculated) ................................ 1
Pages of auto-vacuum overhead ..................................... 0 0.00%
Number of tables in the database .................................. 2
Number of indices ................................................. 4
Number of defined indices ......................................... 4
Number of implied indices ......................................... 0
Size of the file in bytes: .............................. 17239605248
Bytes of user payload stored ............................. 9568276338 55.50%
*** Page counts for all tables with their indices *****************************
ONTIME ...................................................... 4208886 100.00%
SQLITE_MASTER ..................................................... 1 0.00%
*** Page counts for all tables and indices separately *************************
ONTIME ...................................................... 2584403 61.40%
DATE ......................................................... 479343 11.39%
ORIGIN ....................................................... 391758 9.31%
DEST ......................................................... 391758 9.31%
YEAR ......................................................... 361624 8.59%
SQLITE_MASTER ..................................................... 1 0.00%
*** All tables and indices ****************************************************
Percentage of total database ................................... 100%
Number of entries ......................................... 617674850
Bytes of storage consumed ............................... 17239601152
Bytes of payload ........................................ 14708755663 85.32%
Bytes of metadata ........................................ 2410975976 13.99%
Average payload per entry ..................................... 23.81
Average unused bytes per entry ................................. 0.19
Average metadata per entry ...................................... 3.9
Non-sequential pages .............................................. 1 0.00%
Maximum payload per entry ....................................... 593
Entries that use overflow ......................................... 0 0.00%
Index pages used .............................................. 14182
Primary pages used .......................................... 4194705
Overflow pages used ............................................... 0
Total pages used ............................................ 4208887
Unused bytes on index pages ................................. 3778111 6.50%
Unused bytes on primary pages ............................. 116091402 0.68%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ................................. 119869513 0.70%
*** All tables ****************************************************************
Percentage of total database ............................... 61.4035%
Number of entries ......................................... 123534974
Bytes of storage consumed ............................... 10585718784
Bytes of payload ......................................... 9568277184 90.39%
Bytes of metadata ......................................... 909062568 8.59%
Average payload per entry ..................................... 77.45
Average unused bytes per entry ................................. 0.88
Average metadata per entry ..................................... 7.36
Non-sequential pages .............................................. 1 0.00%
Maximum payload per entry ....................................... 593
Entries that use overflow ......................................... 0 0.00%
Index pages used ............................................... 7207
Primary pages used .......................................... 2577197
Overflow pages used ............................................... 0
Total pages used ............................................ 2584404
Unused bytes on index pages ................................. 3706127 12.55%
Unused bytes on primary pages ............................. 104672905 0.99%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ................................. 108379032 1.02%
*** All indices ***************************************************************
Percentage of total database ............................... 38.5965%
Number of entries ......................................... 494139876
Bytes of storage consumed ................................ 6653882368
Bytes of payload ......................................... 5140478479 77.26%
Bytes of metadata ........................................ 1501913408 22.57%
Average payload per entry ...................................... 10.4
Average unused bytes per entry ................................. 0.02
Average metadata per entry ..................................... 3.04
Non-sequential pages .............................................. 0 0.00%
Maximum payload per entry ........................................ 13
Entries that use overflow ......................................... 0 0.00%
Index pages used ............................................... 6975
Primary pages used .......................................... 1617508
Overflow pages used ............................................... 0
Total pages used ............................................ 1624483
Unused bytes on index pages ................................... 71984 0.25%
Unused bytes on primary pages .............................. 11418497 0.17%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages .................................. 11490481 0.17%
*** Table ONTIME and all its indices ******************************************
Percentage of total database ................................... 100%
Number of entries ......................................... 617674845
Bytes of storage consumed ............................... 17239597056
Bytes of payload ........................................ 14708754817 85.32%
Bytes of metadata ........................................ 2410975847 13.99%
Average payload per entry ..................................... 23.81
Average unused bytes per entry ................................. 0.19
Average metadata per entry ...................................... 3.9
Non-sequential pages .............................................. 1 0.00%
Maximum payload per entry ........................................ 88
Entries that use overflow ......................................... 0 0.00%
Index pages used .............................................. 14182
Primary pages used .......................................... 4194704
Overflow pages used ............................................... 0
Total pages used ............................................ 4208886
Unused bytes on index pages ................................. 3778111 6.50%
Unused bytes on primary pages ............................. 116088281 0.68%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ................................. 119866392 0.70%
*** Table ONTIME w/o any indices **********************************************
Percentage of total database ............................... 61.4035%
Number of entries ......................................... 123534969
Bytes of storage consumed ............................... 10585714688
Bytes of payload ......................................... 9568276338 90.39%
Bytes of metadata ......................................... 909062439 8.59%
B-tree depth ...................................................... 4
Average payload per entry ..................................... 77.45
Average unused bytes per entry ................................. 0.88
Average metadata per entry ..................................... 7.36
Non-sequential pages .............................................. 1 0.00%
Maximum payload per entry ........................................ 88
Entries that use overflow ......................................... 0 0.00%
Index pages used ............................................... 7207
Primary pages used .......................................... 2577196
Overflow pages used ............................................... 0
Total pages used ............................................ 2584403
Unused bytes on index pages ................................. 3706127 12.55%
Unused bytes on primary pages ............................. 104669784 0.99%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ................................. 108375911 1.02%
*** Index ONTIME of table DATE ************************************************
Percentage of total database ............................... 11.3888%
Number of entries ......................................... 123534969
Bytes of storage consumed ................................ 1963388928
Bytes of payload ......................................... 1583228866 80.64%
Bytes of metadata ......................................... 376357019 19.17%
B-tree depth ...................................................... 4
Average payload per entry ..................................... 12.82
Average unused bytes per entry ................................. 0.03
Average metadata per entry ..................................... 3.05
Non-sequential pages .............................................. 0 0.00%
Maximum payload per entry ........................................ 13
Entries that use overflow ......................................... 0 0.00%
Index pages used ............................................... 2322
Primary pages used ........................................... 477021
Overflow pages used ............................................... 0
Total pages used ............................................. 479343
Unused bytes on index pages ................................... 25148 0.26%
Unused bytes on primary pages ............................... 3777895 0.19%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ................................... 3803043 0.19%
*** Index ONTIME of table DEST ************************************************
Percentage of total database ............................... 9.30787%
Number of entries ......................................... 123534969
Bytes of storage consumed ................................ 1604640768
Bytes of payload ......................................... 1226928194 76.46%
Bytes of metadata ......................................... 375305999 23.39%
B-tree depth ...................................................... 4
Average payload per entry ...................................... 9.93
Average unused bytes per entry ................................. 0.02
Average metadata per entry ..................................... 3.04
Non-sequential pages .............................................. 0 0.00%
Maximum payload per entry ........................................ 10
Entries that use overflow ......................................... 0 0.00%
Index pages used ............................................... 1622
Primary pages used ........................................... 390136
Overflow pages used ............................................... 0
Total pages used ............................................. 391758
Unused bytes on index pages ................................... 16644 0.25%
Unused bytes on primary pages ............................... 2389931 0.15%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ................................... 2406575 0.15%
*** Index ONTIME of table ORIGIN **********************************************
Percentage of total database ............................... 9.30787%
Number of entries ......................................... 123534969
Bytes of storage consumed ................................ 1604640768
Bytes of payload ......................................... 1226928194 76.46%
Bytes of metadata ......................................... 375305999 23.39%
B-tree depth ...................................................... 4
Average payload per entry ...................................... 9.93
Average unused bytes per entry ................................. 0.02
Average metadata per entry ..................................... 3.04
Non-sequential pages .............................................. 0 0.00%
Maximum payload per entry ........................................ 10
Entries that use overflow ......................................... 0 0.00%
Index pages used ............................................... 1622
Primary pages used ........................................... 390136
Overflow pages used ............................................... 0
Total pages used ............................................. 391758
Unused bytes on index pages ................................... 16638 0.25%
Unused bytes on primary pages ............................... 2389937 0.15%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ................................... 2406575 0.15%
*** Index ONTIME of table YEAR ************************************************
Percentage of total database ............................... 8.59191%
Number of entries ......................................... 123534969
Bytes of storage consumed ................................ 1481211904
Bytes of payload ......................................... 1103393225 74.49%
Bytes of metadata ......................................... 374944391 25.31%
B-tree depth ...................................................... 4
Average payload per entry ...................................... 8.93
Average unused bytes per entry ................................. 0.02
Average metadata per entry ..................................... 3.04
Non-sequential pages .............................................. 0 0.00%
Maximum payload per entry ......................................... 9
Entries that use overflow ......................................... 0 0.00%
Index pages used ............................................... 1409
Primary pages used ........................................... 360215
Overflow pages used ............................................... 0
Total pages used ............................................. 361624
Unused bytes on index pages ................................... 13554 0.23%
Unused bytes on primary pages ............................... 2860734 0.19%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ................................... 2874288 0.19%
*** Table SQLITE_MASTER *******************************************************
Percentage of total database ........................... 2.37592e-05%
Number of entries ................................................. 5
Bytes of storage consumed ...................................... 4096
Bytes of payload ................................................ 846 20.65%
Bytes of metadata ............................................... 129 3.15%
B-tree depth ...................................................... 1
Average payload per entry ..................................... 169.2
Average unused bytes per entry ................................ 624.2
Average metadata per entry ..................................... 25.8
Maximum payload per entry ....................................... 593
Entries that use overflow ......................................... 0 0.00%
Primary pages used ................................................ 1
Overflow pages used ............................................... 0
Total pages used .................................................. 1
Unused bytes on primary pages .................................. 3121 76.20%
Unused bytes on overflow pages .................................... 0 0.00%
Unused bytes on all pages ...................................... 3121 76.20%
*** Definitions ***************************************************************
Page size in bytes
The number of bytes in a single page of the database file.
Usually 1024.
Number of pages in the whole file
The number of 4096-byte pages that go into forming the complete
database
Pages that store data
The number of pages that store data, either as primary B*Tree pages or
as overflow pages. The number at the right is the data pages divided by
the total number of pages in the file.
Pages on the freelist
The number of pages that are not currently in use but are reserved for
future use. The percentage at the right is the number of freelist pages
divided by the total number of pages in the file.
Pages of auto-vacuum overhead
The number of pages that store data used by the database to facilitate
auto-vacuum. This is zero for databases that do not support auto-vacuum.
Number of tables in the database
The number of tables in the database, including the SQLITE_MASTER table
used to store schema information.
Number of indices
The total number of indices in the database.
Number of defined indices
The number of indices created using an explicit CREATE INDEX statement.
Number of implied indices
The number of indices used to implement PRIMARY KEY or UNIQUE constraints
on tables.
Size of the file in bytes
The total amount of disk space used by the entire database files.
Bytes of user payload stored
The total number of bytes of user payload stored in the database. The
schema information in the SQLITE_MASTER table is not counted when
computing this number. The percentage at the right shows the payload
divided by the total file size.
Percentage of total database
The amount of the complete database file that is devoted to storing
information described by this category.
Number of entries
The total number of B-Tree key/value pairs stored under this category.
Bytes of storage consumed
The total amount of disk space required to store all B-Tree entries
under this category. The is the total number of pages used times
the pages size.
Bytes of payload
The amount of payload stored under this category. Payload is the data
part of table entries and the key part of index entries. The percentage
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 in 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 neither
unused space nor content. The record header in the payload is counted as
content, not metadata.
Average payload per entry
The average amount of payload on each entry. This is just the bytes of
payload divided by the number of entries.
Average unused bytes per entry
The average amount of free space remaining on all pages under this
category on a per-entry basis. This is the number of unused bytes on
all pages divided by the number of entries.
Non-sequential pages
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
The largest payload size of any entry.
Entries that use overflow
The number of entries that user one or more overflow pages.
Total pages used
This is the number of pages used to hold all information in the current
category. This is the sum of index, primary, and overflow pages.
Index pages used
This is the number of pages in a table B-tree that hold only key (rowid)
information and no data.
Primary pages used
This is the number of B-tree pages that hold both key and data.
Overflow pages used
The total number of overflow pages used for this category.
Unused bytes on index pages
The total number of bytes of unused space on all index pages. The
percentage at the right is the number of unused bytes divided by the
total number of bytes on index pages.
Unused bytes on primary pages
The total number of bytes of unused space on all primary pages. The
percentage at the right is the number of unused bytes divided by the
total number of bytes on primary pages.
Unused bytes on overflow pages
The total number of bytes of unused space on all overflow pages. The
percentage at the right is the number of unused bytes divided by the
total number of bytes on overflow pages.
Unused bytes on all pages
The total number of bytes of unused space on all primary and overflow
pages. The percentage at the right is the number of unused bytes
divided by the total number of bytes.
*******************************************************************************
The entire text of this report can be sourced into any SQL database
engine for further analysis. All of the text above is an SQL comment.
The data used to generate this report follows:
*/
BEGIN TRANSACTION;
CREATE TABLE space_used(
name clob, -- Name of a table or index in the database file
tblname clob, -- Name of associated table
is_index boolean, -- TRUE if it is an index, false for a table
is_without_rowid boolean, -- TRUE if WITHOUT ROWID table
nentry int, -- Number of entries in the BTree
leaf_entries int, -- Number of leaf entries
depth int, -- Depth of the b-tree
payload int, -- Total amount of data stored in this table or index
ovfl_payload int, -- Total amount of data stored on overflow pages
ovfl_cnt int, -- Number of entries that use overflow
mx_payload int, -- Maximum payload size
int_pages int, -- Number of interior pages used
leaf_pages int, -- Number of leaf pages used
ovfl_pages int, -- Number of overflow pages used
int_unused int, -- Number of unused bytes on interior pages
leaf_unused int, -- Number of unused bytes on primary pages
ovfl_unused int, -- Number of unused bytes on overflow pages
gap_cnt int, -- Number of gaps in the page layout
compressed_size int -- Total bytes stored on disk
);
INSERT INTO "space_used" VALUES('ontime','ontime',0,0,126112164,123534969,4,9568276338,0,0,88,7207,2577196,0,3706127,104669784,0,1,10585714688);
INSERT INTO "space_used" VALUES('sqlite_master','sqlite_master',0,0,5,5,1,846,0,0,593,0,1,0,0,3121,0,0,4096);
INSERT INTO "space_used" VALUES('year','ontime',1,0,123534969,123174755,4,1103393225,0,0,9,1409,360215,0,13554,2860734,0,0,1481211904);
INSERT INTO "space_used" VALUES('date','ontime',1,0,123534969,123057949,4,1583228866,0,0,13,2322,477021,0,25148,3777895,0,0,1963388928);
INSERT INTO "space_used" VALUES('origin','ontime',1,0,123534969,123144834,4,1226928194,0,0,10,1622,390136,0,16638,2389937,0,0,1604640768);
INSERT INTO "space_used" VALUES('dest','ontime',1,0,123534969,123144834,4,1226928194,0,0,10,1622,390136,0,16644,2389931,0,0,1604640768);
COMMIT;