文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 25 MySQL NDB 集群 8.4 / 25.5 NDB 集群程序 / 25.5.14 ndb_index_stat — NDB 索引统计实用程序
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 68%

25.5.14 ndb_index_stat — NDB 索引统计工具25.5.14 ndb_index_stat — NDB Index Statistics Utility

ndb_index_stat 提供有关 NDB 表索引的每个分片的统计信息。这包括缓存版本和年龄、每个分区的索引条目数量,以及索引的内存消耗。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

要获取给定 NDB 表的基本索引统计信息,请按如下方式调用 ndb_index_stat,将表名作为第一个参数,并在其后立即指定包含该表的数据库名称,使用 --database (-d) 选项: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

在此示例中,我们使用 ndb_index_stat 来获取关于 test 数据库中名为 mytable 的 NDB 表的此类信息: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

sampleVersion 是缓存的版本号,从中获取统计数据。使用 ndb_index_stat 并带上 --update 选项将导致 sampleVersion 增加。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 显示缓存最后更新时间。该时间以自 Unix 纪元以来的秒数表示。loadTime shows when the cache was last updated. This is expressed as seconds since the Unix Epoch.

sampleCount 是每个分区找到的索引条目数。你可以通过将其乘以片段数(显示为 fragCount)来估算条目总数。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 可以与 SHOW INDEX 或 INFORMATION_SCHEMA.STATISTICS 的基数进行比较,尽管后两者提供的是整个表的视图,而 ndb_index_stat 提供的是每个分片的平均值。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 是索引使用的字节数。在这个例子中,主键是一个整数,每个索引需要四个字节,因此 keyBytes 在这种情况下可以按如下方式计算: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

这些信息也可以使用来自 INFORMATION_SCHEMA.COLUMNS 的相应列定义获取(这需要 MySQL 服务器和 MySQL 客户端应用程序)。This information can also be obtained using the corresponding column definitions from INFORMATION_SCHEMA.COLUMNS (this requires a MySQL Server and a MySQL client application).

totalBytes 是表上所有索引所占用的总内存,以字节为单位。totalBytes is the total memory consumed by all indexes on the table, in bytes.

前面示例中显示的时间是针对每次调用 ndb_index_stat 的特定时间。Timings shown in the preceding examples are specific to each invocation of ndb_index_stat.

--verbose 选项提供了一些额外的输出,如下所示: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

$>

如果程序的输出为空,这可能表示尚不存在任何统计信息。要强制创建它们(或者如果它们已经存在则更新它们),请使用 ndb_index_stat 命令并加上 --update 选项,或者在 mysql 客户端中对表执行 ANALYZE TABLE 命令。If the output from the program is empty, 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

下表包含 NDB 集群 ndb_index_stat 工具的特定选项。表格之后列出了附加说明。The following table includes options that are specific to the NDB Cluster ndb_index_stat utility. Additional descriptions are listed following the table.

  • --character-sets-dir

    命令行格式Command-Line Format --character-sets-dir=path--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][none]

    同 --ndb-connectstring。Same as --ndb-connectstring.

  • --core-file

    命令行格式Command-Line Format --core-file

    错误时生成核心文件;用于调试。Write core file on error; used in debugging.

  • --database=name, -d name

    命令行格式Command-Line Format --database=name
    类型Type 字符串String
    默认值Default Value [none][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--defaults-extra-file=path
    类型Type 字符串String
    默认值Default Value [none][none]

    在读取全局文件之后读取给定文件。Read given file after global files are read.

  • --defaults-file

    命令行格式Command-Line Format --defaults-file=path
    类型Type 字符串String
    默认值Default Value [none][none]

    仅从指定文件读取默认选项。Read default options from given file only.

  • --defaults-group-suffix

    命令行格式Command-Line Format --defaults-group-suffix=string
    类型Type 字符串String
    默认值Default Value [none][none]

    也读取组合了 concat(group, suffix) 的组。Also read groups with concat(group, suffix).

  • --delete

    命令行格式Command-Line Format --delete

    删除指定表的索引统计信息,停止此前配置的任何自动更新。Delete the index statistics for the given table, stopping any auto-update that was previously configured.

  • --dump

    命令行格式Command-Line Format --dump

    转储查询缓存的内容。Dump the contents of the query cache.

  • --help

    命令行格式Command-Line Format --help--help

    显示帮助文本并退出。Display help text and exit.

  • --login-path

    命令行格式Command-Line Format --login-path=path
    类型Type 字符串String
    默认值Default Value [none][none]

    从登录文件读取给定路径。Read given path from login file.

  • --no-login-paths

    命令行格式Command-Line Format --no-login-paths

    跳过从登录路径文件读取选项。Skips reading options from the login path file.

  • --loops=#

    命令行格式Command-Line Format --loops=#
    类型Type 数字Numeric
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value MAX_INTMAX_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][none]

    设置用于连接到 ndb_mgmd 的连接字符串。语法:[nodeid=id;][host=]hostname[:port]。覆盖 NDB_CONNECTSTRING 和 my.cnf 中的条目。Set connection string for connecting to ndb_mgmd. Syntax: [nodeid=id;][host=]hostname[:port]. Overrides entries in NDB_CONNECTSTRING and my.cnf.

  • --ndb-mgm-tls

    命令行格式Command-Line Format --ndb-mgm-tls=level
    类型Type 枚举Enumeration
    默认值Default Value relaxedrelaxed
    有效值Valid Values

    relaxedrelaxed

    strictstrict

    设置连接到管理服务器所需的 TLS 支持级别;可以是 relaxed 或 strict。relaxed(默认)表示尝试建立 TLS 连接,但不要求成功;strict表示连接必须使用 TLS。Sets the level of TLS support required to connect to the management server; one of relaxed or strict. relaxed (the default) means that a TLS connection is attempted, but success is not required; strict means that TLS is required to connect.

  • --ndb-mgmd-host

    命令行格式Command-Line Format --ndb-mgmd-host=connection_string
    类型Type 字符串String
    默认值Default Value [none][none]

    同 --ndb-connectstring。Same as --ndb-connectstring.

  • --ndb-nodeid

    命令行格式Command-Line Format --ndb-nodeid=#
    类型Type 整数Integer
    默认值Default Value [none][none]

    为此节点设置节点 ID,覆盖由 --ndb-connectstring 设置的任何 ID。Set node ID for this node, overriding any ID set by --ndb-connectstring.

  • --ndb-optimized-node-selection

    命令行格式Command-Line Format --ndb-optimized-node-selection

    启用事务节点选择的优化。默认启用;使用 --skip-ndb-optimized-node-selection 来禁用。Enable optimizations for selection of nodes for transactions. Enabled by default; use --skip-ndb-optimized-node-selection to disable.

  • --ndb-tls-search-path

    命令行格式Command-Line Format --ndb-tls-search-path=list
    类型Type 路径名Path name
    默认值(Unix)Default Value (Unix) $HOME/ndb-tls$HOME/ndb-tls
    默认值(Windows)Default Value (Windows) $HOMEDIR/ndb-tls

    指定用于搜索 CA 文件的目录列表。在 Unix 平台上,目录名称用冒号 (:) 分隔;在 Windows 系统上,使用分号 (;) 作为分隔符。目录引用可以是相对路径或绝对路径;它可以包含一个或多个环境变量,每个变量以美元符号 ($) 开头,并在使用前进行展开。Specify a list of directories to search for a CA file. On Unix platforms, the directory names are separated by colons (:); on Windows systems, the semicolon character (;) is used as the separator. A directory reference may be relative or absolute; it may contain one or more environment variables, each denoted by a prefixed dollar sign ($), and expanded prior to use.

    搜索从最左边的命名目录开始,按从左到右的顺序进行,直到找到文件。空字符串表示空搜索路径,这会导致所有搜索失败。由单个点 (.) 组成的字符串表示搜索路径仅限于当前工作目录。Searching begins with the leftmost named directory and proceeds from left to right until a file is found. An empty string denotes an empty search path, which causes all searches to fail. A string consisting of a single dot (.) indicates that the search path limited to the current working directory.

    如果未提供搜索路径,则使用编译时的默认值。此值取决于所使用的平台:在 Windows 上,它是 \ndb-tls;在其他平台(包括 Linux)上,它是 $HOME/ndb-tls。可以通过使用 -DWITH_NDB_TLS_SEARCH_PATH 编译 NDB Cluster 来覆盖该值。If no search path is supplied, the compiled-in default value is used. This value depends on the platform used: On Windows, this is \ndb-tls; on other platforms (including Linux), it is $HOME/ndb-tls. This can be overridden by compiling NDB Cluster using -DWITH_NDB_TLS_SEARCH_PATH.

  • --no-defaults

    命令行格式Command-Line Format --no-defaults--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_INTMAX_INT

    对第一个键属性执行随机范围查询(必须是无符号整数)。Perform random range queries on first key attribute (must be int unsigned).

  • --sys-drop

    命令行格式Command-Line Format --sys-drop

    删除 NDB 内核中的所有统计表和事件。这将导致所有统计数据丢失。Drop all statistics tables and events in the NDB kernel. This causes all statistics to be lost.

  • --sys-create

    命令行格式Command-Line Format --sys-create

    在 NDB 内核中创建所有统计表和事件。仅在它们之前不存在时才有效。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

    在程序调用时创建任何尚不存在的 NDB 系统统计表或事件(或两者)。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

    创建任何当前不存在的 NDB 系统统计表或事件,在删除任何无效的表或事件之后。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

    验证 NDB 内核中所有必需的系统统计表和事件是否存在。Verify that all required system statistics tables and events exist in the NDB kernel.

  • --sys-skip-tables

    命令行格式Command-Line Format --sys-skip-tables

    不要对任何统计表应用 --sys-* 选项。Do not apply any --sys-* options to any statistics tables.

  • --sys-skip-events

    命令行格式Command-Line Format --sys-skip-events

    不要将任何 --sys-* 选项应用到任何事件。Do not apply any --sys-* options to any events.

  • --update

    命令行格式Command-Line Format --update

    更新给定表的索引统计信息,并重新启动之前配置的任何自动更新。Update the index statistics for the given table, and restart any auto-update that was previously configured.

  • --usage

    命令行格式Command-Line Format --usage

    显示帮助文本并退出;与 --help 相同。Display help text and exit; same as --help.

  • --verbose

    命令行格式Command-Line Format --verbose--verbose

    开启详细输出。Turn on verbose output.

  • --version

    命令行格式Command-Line Format --version

    显示版本信息并退出。Display version information and exit.

ndb_index_stat 系统选项。 以下选项用于在 NDB 内核中生成和更新统计表。 这些选项都不能与统计选项混合使用(请参见 ndb_index_stat 统计选项)。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 统计选项。 这里列出的选项用于生成索引统计信息。它们适用于指定的表和数据库。它们不能与系统选项混合使用(参见 ndb_index_stat 系统选项)。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).