25.5.14 NDB 索引统计实用程序 — ndb_index_stat
ndb_index_stat 提供了关于 NDB 表的每个片段索引统计信息,包括缓存版本和年龄、每个分区中的索引条目数量和索引占用的内存。
要获得基本索引统计信息关于某个 NDB 表,可以使用 ndb_index_stat,如下所示,将表名作为第一个参数,并使用 --database 选项指定包含该表的数据库名称:
ndb_index_stat table -d database
在这个例子中,我们使用 ndb_index_stat 获得名为 mytable 的 NDB 表在名为 test 的数据库中的索引信息:
$> 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递增。
loadTime 显示了缓存最后一次更新的时间,这是以Unix纪元为基准的秒数。
sampleCount 是每个分区中找到索引条目的数量。您可以通过将其乘以fragCount来估算总的条目数。
sampleCount 可与SHOW INDEX或INFORMATION_SCHEMA.STATISTICS进行比较,虽然后两个提供了整个表的视图,而ndb_index_stat提供了每个分区的平均值。
keyBytes 是索引使用的字节数。在这个示例中,主键是一个整数,它需要四个字节来存储索引,因此可以根据以下方式计算:
keyBytes = sampleCount * (4 bytes per index) = 1994 * 4 = 7976
可以使用对应的列定义从INFORMATION_SCHEMA.COLUMNS(需要 MySQL 服务器和 MySQL 客户端应用程序)获取该信息。
totalBytes 是表中的所有索引占用的总内存大小,单位为字节。
前面的示例中显示的时间是对ndb_index_stat的每次调用特定的。
使用--verbose选项可以获得一些额外的输出,示例如下:
$> 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选项,或者在ANALYZE TABLE中执行该语句,以便在mysql客户端中。
以下表格包括特定于 NDB 集群ndb_index_stat实用工具的选项。额外描述在表格后面。
-
Command-Line Format --character-sets-dir=路径包含字符集的目录。
-
Command-Line Format --connect-retries=#Type 整数 Default Value 12Minimum Value 0Maximum Value 12连接失败前重试的次数。
-
Command-Line Format --connect-retry-delay=#Type 整数 Default Value 5Minimum Value 0Maximum Value 5与管理服务器联系失败后等待的秒数。
-
Command-Line Format --connect-string=connection_stringType 字符串 Default Value [none] -
Command-Line Format --core-file在调试时写入核心文件;用于错误处理。
-
--database=,name-dnameCommand-Line Format --database=nameType 字符串 Default Value [none]Minimum Value Maximum Value 包含被查询表的数据库名称。
-
Command-Line Format --defaults-extra-file=pathType 字符串 Default Value [none]在读取全局文件后读取给定的文件。
-
--徽水缾-fileCommand-Line Format --徽水缾-file=pathType String Default Value [none]从给定的文件中读取默认选项。
-
--徽水缾-group-suffixCommand-Line Format --徽水缾-group-suffix=stringType String Default Value [none]也读取concat(组,后缀)中的组。
-
--徽水缾-deleteCommand-Line Format --徽水缾-delete删除给定表的索引统计信息,停止之前配置的自动更新。
-
--徽水缾-dumpCommand-Line Format --徽水缾-dump将查询缓存的内容导出。
-
--徽水缾-helpCommand-Line Format --徽水缾-help显示帮助文本并退出。
-
Command-Line Format --login-path=pathType String Default Value [none]从登录文件中读取给定的路径。
-
Command-Line Format --no-login-paths跳过从登录路径文件中读取选项。
-
Command-Line Format --loops=#Type Numeric Default Value 0Minimum Value 0Maximum Value MAX_INT重复命令这个次数(用于测试)。
-
Command-Line Format --ndb-connectstring=connection_stringType String Default Value [none]设置连接字符串以连接到ndb_ mgmd。语法:
[nodeid=。覆盖了id;][host=]hostname[:port]NDB_ CONNECTSTRING和my. cnf中的条目。 -
Command-Line Format --ndb-mgm-tls=levelType 枚举 Default Value relaxedValid Values relaxedstrict设置连接到管理服务器所需的 TLS 支持级别;可以是
relaxed或strict。relaxed(默认)表示尝试建立 TLS 连接,但不要求成功;strict表示需要 TLS 连接以连接。 -
Command-Line Format --ndb-mgmd-host=connection_stringType 字符串 Default Value [none] -
Command-Line Format --ndb-nodeid=#Type Integer Default Value [none]将节点ID设置为该节点,覆盖由
--ndb-connectstring设置的任何ID。 -
--ndb-optimized-node-selectionCommand-Line Format --ndb-optimized-node-selection启用事务节点选择优化。默认启用,可以使用
--skip-ndb-optimized-node-selection来禁用。 -
Command-Line Format --ndb-tls-search-path=列表Type 路径名称 Default Value (Unix) $HOME/ndb-tlsDefault Value (Windows) $HOMEDIR/ndb-tls指定搜索CA文件的目录列表。Unix 平台上,目录名称使用冒号(
:)分隔;Windows 系统上,使用分号字符(;)作为分隔符。目录引用可以是相对或绝对路径,可以包含一个或多个环境变量,每个变量以前缀的美元符号($)表示,并在使用时展开。搜索从最左侧的命名目录开始,自左向右直到找到文件为止。空字符串表示空搜索路径,这将导致所有搜索失败。由单个点 (
.) 组成的字符串表示搜索路径限制于当前工作目录。如果未提供搜索路径,编译时默认值将被使用。这取决于平台:在 Windows 上,这是
\ndb-tls;在其他平台(包括 Linux)上,这是$HOME/ndb-tls。可以通过编译 NDB 集群时使用-DWITH_NDB_TLS_SEARCH_PATH来覆盖该值。 -
Command-Line Format --no-defaults不从任何选项文件中读取默认选项,除了登录文件。
-
Command-Line Format --print-defaults打印程序参数列表并退出。
-
Command-Line Format --query=#Type 数字 Default Value 0Minimum Value 0Maximum Value MAX_INT对第一个键属性执行随机范围查询(必须是无符号整数)。
-
Command-Line Format --sys-drop在 NDB 内核中删除所有统计表和事件。这将导致所有统计数据丢失。
-
Command-Line Format --sys-create在 NDB 内核中创建所有统计表和事件。这只对之前不存在的表和事件有效。
-
Command-Line Format --sys-create-if-not-exist在程序启动时,创建 NDB 系统统计表或事件(或两者)如果它们不存在。
-
Command-Line Format --sys-create-if-not-valid在删除无效的统计表和事件后,创建 NDB 系统统计表或事件如果它们不存在。
-
Command-Line Format --sys-检查验证 NDB 内核中所有必需的系统统计表和事件是否存在。
-
Command-Line Format --sys-skip-表不对任何统计表应用
--sys-*选项。 -
Command-Line Format --sys-skip-事件不对任何事件应用
--sys-*选项。 -
Command-Line Format --update更新给定表的索引统计信息,并重新启动之前配置的自动更新。
-
Command-Line Format --usage显示帮助文本并退出;与
--help相同。 -
Command-Line Format --verbose启用详细输出。
-
Command-Line Format --version显示版本信息并退出。
ndb_index_stat 系统选项 。以下选项用于在 NDB 内核中生成和更新统计表。这些选项不能与统计选项混用(见ndb_index_stat 统计选项)。
ndb_索引统计选项. 列出的选项用于生成索引统计信息。它们与给定的表和数据库一起工作。它们不能与系统选项混用(见ndb_索引_stat 系统选项)。