ndb_index_stat provides per-fragment
statistical information about indexes on NDB
tables. This includes cache version and age, number of index
entries per partition, and memory consumption by indexes.
Usage
To obtain basic index statistics about a given
NDB table, invoke
ndb_index_stat as shown here, with the name
of the table as the first argument and the name of the database
containing this table specified immediately following it, using
the --database
(-d) option:
ndb_index_stat table -d database
In this example, we use ndb_index_stat to
obtain such information about an NDB table
named mytable in the test
database:
$> ndb_index_stat -d test mytable
table:City index:PRIMARY fragCount:2
sampleVersion:3 loadTime:1399585986 sampleCount:1994 keyBytes:7976
query cache: valid:1 sampleCount:1994 totalBytes:27916
times in ms: save: 7.133 sort: 1.974 sort per sample: 0.000
NDBT_ProgramExit: 0 - OK
sampleVersion is the version number of the
cache from which the statistics data is taken. Running
ndb_index_stat with the
--update option causes
sampleVersion to be incremented.
loadTime shows when the cache was last
updated. This is expressed as seconds since the Unix Epoch.
sampleCount is the number of index entries
found per partition. You can estimate the total number of
entries by multiplying this by the number of fragments (shown as
fragCount).
sampleCount can be compared with the
cardinality of SHOW INDEX or
INFORMATION_SCHEMA.STATISTICS,
although the latter two provide a view of the table as a whole,
while ndb_index_stat provides a per-fragment
average.
keyBytes is the number of bytes used by the
index. In this example, the primary key is an integer, which
requires four bytes for each index, so
keyBytes can be calculated in this case as
shown here:
keyBytes = sampleCount * (4 bytes per index) = 1994 * 4 = 7976
This information can also be obtained using the corresponding
column definitions from the Information Schema
COLUMNS table (this requires a
MySQL Server and a MySQL client application).
totalBytes is the total memory consumed by
all indexes on the table, in bytes.
Timings shown in the preceding examples are specific to each invocation of ndb_index_stat.
The --verbose option
provides some additional output, as shown here:
$> ndb_index_stat -d test mytable --verbose
random seed 1337010518
connected
loop 1 of 1
table:mytable index:PRIMARY fragCount:4
sampleVersion:2 loadTime:1336751773 sampleCount:0 keyBytes:0
read stats
query cache created
query cache: valid:1 sampleCount:0 totalBytes:0
times in ms: save: 20.766 sort: 0.001
disconnected
NDBT_ProgramExit: 0 - OK
$>
If the only output from the program is
NDBT_ProgramExit: 0 - OK, this may indicate
that no statistics yet exist. To force them to be created (or
updated if they already exist), invoke
ndb_index_stat with the
--update option, or
execute ANALYZE TABLE on the
table in the mysql client.
Options
The following table includes options that are specific to the NDB Cluster ndb_index_stat utility. Additional descriptions are listed following the table.
Table 21.34 Command-line options used with the program ndb_index_stat
| Format | Description | Added, Deprecated, or Removed |
|---|---|---|
| Directory containing character sets | (Supported in all NDB releases based on MySQL 5.7) |
|
| Number of times to retry connection before giving up | (Supported in all NDB releases based on MySQL 5.7) |
|
| Number of seconds to wait between attempts to contact management server | (Supported in all NDB releases based on MySQL 5.7) |
|
| Same as --ndb-connectstring | (Supported in all NDB releases based on MySQL 5.7) |
|
| Write core file on error; used in debugging | (Supported in all NDB releases based on MySQL 5.7) |
|
| Name of database containing table | (Supported in all NDB releases based on MySQL 5.7) |
|
| Read given file after global files are read | (Supported in all NDB releases based on MySQL 5.7) |
|
| Read default options from given file only | (Supported in all NDB releases based on MySQL 5.7) |
|
| Also read groups with concat(group, suffix) | (Supported in all NDB releases based on MySQL 5.7) |
|
| Delete index statistics for table, stopping any auto-update previously configured | (Supported in all NDB releases based on MySQL 5.7) |
|
| Print query cache | (Supported in all NDB releases based on MySQL 5.7) |
|
| Display help text and exit | (Supported in all NDB releases based on MySQL 5.7) |
|
| Read given path from login file | (Supported in all NDB releases based on MySQL 5.7) |
|
| Set the number of times to perform given command; default is 0 | (Supported in all NDB releases based on MySQL 5.7) |
|
| Set connect string for connecting to ndb_mgmd. Syntax: "[nodeid=id;][host=]hostname[:port]". Overrides entries in NDB_CONNECTSTRING and my.cnf | (Supported in all NDB releases based on MySQL 5.7) |
|
| Same as --ndb-connectstring | (Supported in all NDB releases based on MySQL 5.7) |
|
| Set node ID for this node, overriding any ID set by --ndb-connectstring | (Supported in all NDB releases based on MySQL 5.7) |
|
| Enable optimizations for selection of nodes for transactions. Enabled by default; use --skip-ndb-optimized-node-selection to disable | (Supported in all NDB releases based on MySQL 5.7) |
|
| Do not read default options from any option file other than login file | (Supported in all NDB releases based on MySQL 5.7) |
|
| Print program argument list and exit | (Supported in all NDB releases based on MySQL 5.7) |
|
| Perform random range queries on first key attr (must be int unsigned) | (Supported in all NDB releases based on MySQL 5.7) |
|
| Drop any statistics tables and events in NDB kernel (all statistics are lost) | (Supported in all NDB releases based on MySQL 5.7) |
|
| Create all statistics tables and events in NDB kernel, if none of them already exist | (Supported in all NDB releases based on MySQL 5.7) |
|
| Create any statistics tables and events in NDB kernel that do not already exist | (Supported in all NDB releases based on MySQL 5.7) |
|
| Create any statistics tables or events that do not already exist in the NDB kernel, after dropping any that are invalid | (Supported in all NDB releases based on MySQL 5.7) |
|
| Verify that NDB system index statistics and event tables exist | (Supported in all NDB releases based on MySQL 5.7) |
|
| Do not apply sys-* options to tables | (Supported in all NDB releases based on MySQL 5.7) |
|
| Do not apply sys-* options to events | (Supported in all NDB releases based on MySQL 5.7) |
|
| Update index statistics for table, restarting any auto-update previously configured | (Supported in all NDB releases based on MySQL 5.7) |
|
| Display help text and exit; same as --help | (Supported in all NDB releases based on MySQL 5.7) |
|
| Turn on verbose output | (Supported in all NDB releases based on MySQL 5.7) |
|
| Display version information and exit | (Supported in all NDB releases based on MySQL 5.7) |
-
Command-Line Format --character-sets-dir=pathDirectory containing character sets.
-
Command-Line Format --connect-retries=#Type Integer Default Value 12Minimum Value 0Maximum Value 12Number of times to retry connection before giving up.
-
Command-Line Format --connect-retry-delay=#Type Integer Default Value 5Minimum Value 0Maximum Value 5Number of seconds to wait between attempts to contact management server.
-
Command-Line Format --connect-string=connection_stringType String Default Value [none]Same as
--ndb-connectstring. -
Command-Line Format --core-fileWrite core file on error; used in debugging.
-
Command-Line Format --database=nameType String Default Value [none]Minimum Value Maximum Value The name of the database that contains the table being queried.
-
Command-Line Format --defaults-extra-file=pathType String Default Value [none]Read given file after global files are read.
-
Command-Line Format --defaults-file=pathType String Default Value [none]Read default options from given file only.
-
Command-Line Format --defaults-group-suffix=stringType String Default Value [none]Also read groups with concat(group, suffix).
-
Command-Line Format --deleteDelete the index statistics for the given table, stopping any auto-update that was previously configured.
-
Command-Line Format --dumpDump the contents of the query cache.
-
Command-Line Format --helpDisplay help text and exit.
-
Command-Line Format --login-path=pathType String Default Value [none]Read given path from login file.
-
Command-Line Format --loops=#Type Numeric Default Value 0Minimum Value 0Maximum Value MAX_INTRepeat commands this number of times (for use in testing).
-
Command-Line Format --ndb-connectstring=connection_stringType String Default Value [none]Set connect string for connecting to ndb_mgmd. Syntax: "[nodeid=id;][host=]hostname[:port]". Overrides entries in NDB_CONNECTSTRING and my.cnf.
-
Command-Line Format --ndb-mgmd-host=connection_stringType String Default Value [none]Same as
--ndb-connectstring. -
Command-Line Format --ndb-nodeid=#Type Integer Default Value [none]Set node ID for this node, overriding any ID set by
--ndb-connectstring. --ndb-optimized-node-selectionCommand-Line Format --ndb-optimized-node-selectionEnable optimizations for selection of nodes for transactions. Enabled by default; use
--skip-ndb-optimized-node-selectionto disable.-
Command-Line Format --no-defaultsDo not read default options from any option file other than login file.
-
Command-Line Format --print-defaultsPrint program argument list and exit.
-
Command-Line Format --query=#Type Numeric Default Value 0Minimum Value 0Maximum Value MAX_INTPerform random range queries on first key attribute (must be int unsigned).
-
Command-Line Format --sys-dropDrop all statistics tables and events in the NDB kernel. This causes all statistics to be lost.
-
Command-Line Format --sys-createCreate all statistics tables and events in the NDB kernel. This works only if none of them exist previously.
-
Command-Line Format --sys-create-if-not-existCreate any NDB system statistics tables or events (or both) that do not already exist when the program is invoked.
-
Command-Line Format --sys-create-if-not-validCreate any NDB system statistics tables or events that do not already exist, after dropping any that are invalid.
-
Command-Line Format --sys-checkVerify that all required system statistics tables and events exist in the NDB kernel.
-
Command-Line Format --sys-skip-tablesDo not apply any
--sys-*options to any statistics tables. -
Command-Line Format --sys-skip-eventsDo not apply any
--sys-*options to any events. -
Command-Line Format --updateUpdate the index statistics for the given table, and restart any auto-update that was previously configured.
-
Command-Line Format --usageDisplay help text and exit; same as
--help. -
Command-Line Format --verboseTurn on verbose output.
-
Command-Line Format --versionDisplay version information and exit.
ndb_index_stat system options. The following options are used to generate and update the statistics tables in the NDB kernel. None of these options can be mixed with statistics options (see ndb_index_stat statistics options).
ndb_index_stat statistics options. The options listed here are used to generate index statistics. They work with a given table and database. They cannot be mixed with system options (see ndb_index_stat system options).