10bet网址
MySQL 8.0 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual

MySQL 8.0 Reference Manual/.../ ndb_index_stat — NDB Index Statistics Utility

23.4.14 ndb_index_stat — NDB Index Statistics Utility

ndb_index_statprovides per-fragment statistical information about indexes onNDBtables. 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 givenNDBtable, invokendb_index_statas 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_stattable-ddatabase

In this example, we usendb_index_statto obtain such information about anNDBtable namedmytablein thetestdatabase:

shell> 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

sampleVersionis the version number of the cache from which the statistics data is taken. Runningndb_index_statwith the--updateoption causes sampleVersion to be incremented.

loadTimeshows when the cache was last updated. This is expressed as seconds since the Unix Epoch.

sampleCountis 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 asfragCount).

sampleCountcan be compared with the cardinality ofSHOW INDEXorINFORMATION_SCHEMA.STATISTICS, although the latter two provide a view of the table as a whole, whilendb_index_statprovides a per-fragment average.

keyBytesis the number of bytes used by the index. In this example, the primary key is an integer, which requires four bytes for each index, sokeyBytescan 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 fromINFORMATION_SCHEMA.COLUMNS(this requires a MySQL Server and a MySQL client application).

totalBytesis the total memory consumed by all indexes on the table, in bytes.

Timings shown in the preceding examples are specific to each invocation ofndb_index_stat.

The--verboseoption provides some additional output, as shown here:

shell> 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 shell>

If the only output from the program isNDBT_ProgramExit: 0 - OK, this may indicate that no statistics yet exist. To force them to be created (or updated if they already exist), invokendb_index_statwith the--updateoption, or executeANALYZE TABLEon the table in themysqlclient.

Options

The following table includes options that are specific to the NDB Clusterndb_index_statutility. Additional descriptions are listed following the table.

Table 23.36 Command-line options used with the program ndb_index_stat

Format Description Added, Deprecated, or Removed

--character-sets-dir=path

Directory containing character sets

(Supported in all NDB releases based on MySQL 8.0)

--connect-retries=#

Number of times to retry connection before giving up

(Supported in all NDB releases based on MySQL 8.0)

--connect-retry-delay=#

Number of seconds to wait between attempts to contact management server

(Supported in all NDB releases based on MySQL 8.0)

--connect-string=connection-string,

-c

Same as --ndb-connectstring

(Supported in all NDB releases based on MySQL 8.0)

--core-file

Write core file on error; used in debugging

(Supported in all NDB releases based on MySQL 8.0)

--database=name,

-d

Name of database containing table

(Supported in all NDB releases based on MySQL 8.0)

--defaults-extra-file=path

Read given file after global files are read

(Supported in all NDB releases based on MySQL 8.0)

--defaults-file=path

Read default options from given file only

(Supported in all NDB releases based on MySQL 8.0)

--defaults-group-suffix=string

Also read groups with concat(group, suffix)

(Supported in all NDB releases based on MySQL 8.0)

--delete

Delete index statistics for table, stopping any auto-update previously configured

(Supported in all NDB releases based on MySQL 8.0)

--dump

Print query cache

(Supported in all NDB releases based on MySQL 8.0)

--help,

-?

Display help text and exit

(Supported in all NDB releases based on MySQL 8.0)

--login-path=path

Read given path from login file

(Supported in all NDB releases based on MySQL 8.0)

--loops=#

Set the number of times to perform given command; default is 0

(Supported in all NDB releases based on MySQL 8.0)

--ndb-connectstring=connection-string,

-c

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 8.0)

--ndb-mgmd-host=connection-string,

-c

Same as --ndb-connectstring

(Supported in all NDB releases based on MySQL 8.0)

--ndb-nodeid=#

Set node ID for this node, overriding any ID set by --ndb-connectstring

(Supported in all NDB releases based on MySQL 8.0)

--ndb-optimized-node-selection

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 8.0)

--no-defaults

Do not read default options from any option file other than login file

(Supported in all NDB releases based on MySQL 8.0)

--print-defaults

Print program argument list and exit

(Supported in all NDB releases based on MySQL 8.0)

--query=#

Perform random range queries on first key attr (must be int unsigned)

(Supported in all NDB releases based on MySQL 8.0)

--sys-drop

Drop any statistics tables and events in NDB kernel (all statistics are lost)

(Supported in all NDB releases based on MySQL 8.0)

--sys-create

Create all statistics tables and events in NDB kernel, if none of them already exist

(Supported in all NDB releases based on MySQL 8.0)

--sys-create-if-not-exist

Create any statistics tables and events in NDB kernel that do not already exist

(Supported in all NDB releases based on MySQL 8.0)

--sys-create-if-not-valid

不创建任何统计数据表或事件already exist in the NDB kernel, after dropping any that are invalid

(Supported in all NDB releases based on MySQL 8.0)

--sys-check

Verify that NDB system index statistics and event tables exist

(Supported in all NDB releases based on MySQL 8.0)

--sys-skip-tables

Do not apply sys-* options to tables

(Supported in all NDB releases based on MySQL 8.0)

--sys-skip-events

Do not apply sys-* options to events

(Supported in all NDB releases based on MySQL 8.0)

--update

Update index statistics for table, restarting any auto-update previously configured

(Supported in all NDB releases based on MySQL 8.0)

--usage,

-?

Display help text and exit; same as --help

(Supported in all NDB releases based on MySQL 8.0)

--verbose,

-v

Turn on verbose output

(Supported in all NDB releases based on MySQL 8.0)

--version,

-V

Display version information and exit

(Supported in all NDB releases based on MySQL 8.0)


  • --character-sets-dir

    Command-Line Format --character-sets-dir=path

    Directory containing character sets.

  • --connect-retries

    Command-Line Format --connect-retries=#
    Type Integer
    Default Value 12
    Minimum Value 0
    Maximum Value 12

    Number of times to retry connection before giving up.

  • --connect-retry-delay

    Command-Line Format --connect-retry-delay=#
    Type Integer
    Default Value 5
    Minimum Value 0
    Maximum Value 5

    Number of seconds to wait between attempts to contact management server.

  • --connect-string

    Command-Line Format --connect-string=connection-string
    Type String
    Default Value [none]

    Same as--ndb-connectstring.

  • --core-file

    Command-Line Format --core-file

    Write core file on error; used in debugging.

  • --database=name,-dname

    Command-Line Format --database=name
    Type String
    Default Value [none]
    Minimum Value
    Maximum Value

    The name of the database that contains the table being queried.

  • --defaults-extra-file

    Command-Line Format --defaults-extra-file=path
    Type String
    Default Value [none]

    Read given file after global files are read.

  • --defaults-file

    Command-Line Format --defaults-file=path
    Type String
    Default Value [none]

    Read default options from given file only.

  • --defaults-group-suffix

    Command-Line Format --defaults-group-suffix=string
    Type String
    Default Value [none]

    Also read groups with concat(group, suffix).

  • --delete

    Command-Line Format --delete
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Delete the index statistics for the given table, stopping any auto-update that was previously configured.

  • --dump

    Command-Line Format --dump
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Dump the contents of the query cache.

  • --help

    Command-Line Format --help

    Display help text and exit.

  • --login-path

    Command-Line Format --login-path=path
    Type String
    Default Value [none]

    Read given path from login file.

  • --loops=#

    Command-Line Format --loops=#
    Type Numeric
    Default Value 0
    Minimum Value 0
    Maximum Value MAX_INT

    Repeat commands this number of times (for use in testing).

  • --ndb-connectstring

    Command-Line Format --ndb-connectstring=connection-string
    Type 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.

  • --ndb-mgmd-host

    Command-Line Format --ndb-mgmd-host=connection-string
    Type String
    Default Value [none]

    Same as--ndb-connectstring.

  • --ndb-nodeid

    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-selection

    Command-Line Format --ndb-optimized-node-selection

    Enable optimizations for selection of nodes for transactions. Enabled by default; use--skip-ndb-optimized-node-selectionto disable.

  • --no-defaults

    Command-Line Format --no-defaults

    Do not read default options from any option file other than login file.

  • --print-defaults

    Command-Line Format --print-defaults

    Print program argument list and exit.

  • --query=#

    Command-Line Format --query=#
    Type Numeric
    Default Value 0
    Minimum Value 0
    Maximum Value MAX_INT

    Perform random range queries on first key attribute (must be int unsigned).

  • --sys-drop

    Command-Line Format --sys-drop
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Drop all statistics tables and events in the NDB kernel.This causes all statistics to be lost.

  • --sys-create

    Command-Line Format --sys-create
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Create all statistics tables and events in the NDB kernel. This works only if none of them exist previously.

  • --sys-create-if-not-exist

    Command-Line Format --sys-create-if-not-exist
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Create any NDB system statistics tables or events (or both) that do not already exist when the program is invoked.

  • --sys-create-if-not-valid

    Command-Line Format --sys-create-if-not-valid
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Create any NDB system statistics tables or events that do not already exist, after dropping any that are invalid.

  • --sys-check

    Command-Line Format --sys-check
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    验证所需的所有系统统计数据表and events exist in the NDB kernel.

  • --sys-skip-tables

    Command-Line Format --sys-skip-tables
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Do not apply any--sys-*options to any statistics tables.

  • --sys-skip-events

    Command-Line Format --sys-skip-events
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Do not apply any--sys-*options to any events.

  • --update

    Command-Line Format --update
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Update the index statistics for the given table, and restart any auto-update that was previously configured.

  • --usage

    Command-Line Format --usage

    Display help text and exit; same as--help.

  • --verbose

    Command-Line Format --verbose
    Type Boolean
    Default Value false
    Minimum Value
    Maximum Value

    Turn on verbose output.

  • --version

    Command-Line Format --version

    Display 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 (seendb_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 (seendb_index_stat system options).