Documentation Source Text

Check-in [6f48ca52cf]
Login

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

Overview
Comment:Initial documentation for the MEMSTAT virtual table.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6f48ca52cf5ea5fc49b5e99a902639c61d867d1ef237baa37ef7e952527b7420
User & Date: drh 2018-09-28 23:43:25.695
Context
2018-10-22
16:07
Update RBU documentation to include REPLACE command rows. (check-in: a9594020c6 user: dan tags: trunk)
2018-09-28
23:43
Initial documentation for the MEMSTAT virtual table. (check-in: 6f48ca52cf user: drh tags: trunk)
20:59
Fix typos on th enew dbpage.html page. (check-in: 966ccc894f user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Added pages/memstat.in.
































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<title>The SQLITE_MEMSTAT Virtual Table</title>
<tcl>hd_keywords sqlite_memstat {SQLITE_MEMSTAT virtual table} \
        {the SQLITE_MEMSTAT extension}</tcl>
<fancy_format>

<h1>Overview</h1>

<p>
The SQLITE_MEMSTAT extension implements an [eponymous-only virtual table] that
provides SQL access to the [sqlite3_status64()] and
[sqlite3_db_status()] interfaces.
</p>

<p>
The SQLITE_STMT extension can also be loaded at run-time
by compiling the extension into a shared library or DLL using the source
code at [https://sqlite.org/src/file/ext/misc/memstat.c] and following the
instructions for how to [compile loadable extensions].
</p>

<h1>Usage</h1>

<p>
The SQLITE_MEMSTAT virtual table is a read-only table that can be
queried to determine performance characteristics (primarily the
amount of memory being used) of the current instance of SQLite.
The SQLITE_MEMSTATE table is essentially a wrapper around the
C-language APIs [sqlite3_status64()] and [sqlite3_db_status()].
If the 
[https://sqlite.org/src/file/ext/misc/memstat.c|memstat.c] source
file is compiled with the -DSQLITE_ENABLE_ZIPVFS option, then SQLITE_MEMSTAT
will also do some [sqlite3_file_control|file-control] calls to extract
memory usage information about the 
[https://www.hwaci.com/sw/sqlite/zipvfs.html | ZIPVFS] subsystem, 
if that subsystem as been licensed, installed, and is in use.

<p>
The SQLITE_MEMSTAT table appears to have the following schema:

<codeblock>
CREATE TABLE sqlite_memstat(
  name TEXT,
  schema TEXT,
  value INT,
  hiwtr INT
);
</codeblock>

<p>
Each row of the SQLITE_MEMSTAT table corresponds to a single call to
one of the [sqlite3_status64()] or [sqlite3_db_status()] interfaces.
The NAME column of the row identifies which "verb" was passed to those
interfaces.  For example, if [sqlite3_status64()] is invoked with
[SQLITE_STATUS_MEMORY_USED], then the NAME column is 'MEMORY_USED'.
Or if [sqlite3_db_status()] is invoked with [SQLITE_DBSTATUS_CACHE_USED],
then the NAME column is "DB_CACHE_USED".

<p>
The SCHEMA column is NULL, except for cases when the [sqlite3_file_control()]
interface is used to interrogate the ZIPVFS backend.  As this only happens
when the memstat.c module is compiled with -DSQLITE_ENABLE_ZIPVFS and when
[https://www.hwaci.com/sw/sqlite/zipvfs.html | ZIPVFS] is in use, 
SCHEMA is usually NULL.

<p>
The VALUE and HIWTR columns report the current value of the measure and
its "high-water mark".  The high-water mark is the highest value ever seen
for the measurement, at least since the last reset.  The SQLITE_MEMSTAT
virtual table does not provide a mechanism for resetting the high-water mark.

<p>
Depending on which parameter is being interrogated, one of the VALUE
or HIWTR mark measurements might be undefined.  For example, only the
high-water mark is meaningful for [SQLITE_STATUS_MALLOC_SIZE], and
only the current value is meaningful for [SQLITE_DBSTATUS_CACHE_USED].
For rows where one or the other of VALUE or HIWTR is not meaningful,
that value is returned as NULL.
the 

interfaces, with the initial
Changes to pages/vtablist.in.
48
49
50
51
52
53
54












55
56
57
58
59
60
61
  doc        *dbstat
  supported  1
  synopsis   {
    Provides information about the purpose and use of each page in a
    database file.  Used in the implementation of the
    [sqlite3_analyzer] utility program.
  }












}
set vtab(pragma) {
  ifdef      builtin
  type       table-valued-function
  src        src/pragma.c
  doc        {*PRAGMA functions}
  supported  1







>
>
>
>
>
>
>
>
>
>
>
>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  doc        *dbstat
  supported  1
  synopsis   {
    Provides information about the purpose and use of each page in a
    database file.  Used in the implementation of the
    [sqlite3_analyzer] utility program.
  }
}
set vtab(sqlite_memstat) {
  ifdef      {}
  type       eponymous
  rw         0
  src        ext/misc/memstat.c
  doc        *sqlite_memstat
  supported  1
  synopsis   {
    Provides SQL access to the [sqlite3_status64()] and
    [sqlite3_db_status()] interfaces.
  }
}
set vtab(pragma) {
  ifdef      builtin
  type       table-valued-function
  src        src/pragma.c
  doc        {*PRAGMA functions}
  supported  1