database-performance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIBM i Database Performance
IBM i 数据库性能
Monitor database performance using index statistics, MTI analysis, database monitors, query supervisor thresholds, and materialized query table tracking.
使用索引统计信息、MTI 分析、数据库监控器、Query Supervisor 阈值和物化查询表跟踪来监控数据库性能。
Available Tools
可用工具
The CLI is the primary tool for executing database performance queries. Set to this skill's installed location (the directory containing this SKILL.md file):
ibmiSKILL_DIRbash
undefinedibmiSKILL_DIRbash
undefinedSKILL_DIR = directory containing this SKILL.md
SKILL_DIR = directory containing this SKILL.md
Examples: ./skills/database-performance, ~/.claude/skills/database-performance
Examples: ./skills/database-performance, ~/.claude/skills/database-performance
List all database performance tools
List all database performance tools
ibmi tools --tools "$SKILL_DIR/tools/" --toolset database_performance_default
ibmi tools --tools "$SKILL_DIR/tools/" --toolset database_performance_default
Run a specific tool
Run a specific tool
ibmi tool get_index_statistics --tools "$SKILL_DIR/tools/"
ibmi tool get_index_statistics --tools "$SKILL_DIR/tools/"
Run with parameters
Run with parameters
ibmi tool get_mti_info --tools "$SKILL_DIR/tools/" --schema-name MYLIB --table-name ORDERS
ibmi tool get_mti_info --tools "$SKILL_DIR/tools/" --schema-name MYLIB --table-name ORDERS
Ad-hoc SQL for custom queries
Ad-hoc SQL for custom queries
ibmi sql "SELECT * FROM QSYS2.SYSINDEXSTAT WHERE TABLE_SCHEMA = 'MYLIB' ORDER BY QUERY_USE_COUNT DESC"
undefinedibmi sql "SELECT * FROM QSYS2.SYSINDEXSTAT WHERE TABLE_SCHEMA = 'MYLIB' ORDER BY QUERY_USE_COUNT DESC"
undefinedService Selection Guide
服务选择指南
Index Analysis
索引分析
- QSYS2.SYSINDEXSTAT -- Index-level statistics: key columns, size, usage counts, build times
- QSYS2.MTI_INFO() -- Maintained Temporary Indexes over a specific table
- QSYS2.SYSINDEXSTAT — 索引级统计信息:键列、大小、使用次数和构建时间
- QSYS2.MTI_INFO() — 特定表上的维护型临时索引
MTI Overhead
MTI 开销
- QSYS2.SYSPARTITIONSTAT -- Partition-level MTI sizes to find tables with high overhead
- QSYS2.SYSPARTITIONSTAT — 分区级 MTI 大小,用于查找开销较高的表
Database Monitoring
数据库监控
- QSYS2.DATABASE_MONITOR_INFO -- Active and inactive database performance monitors
- QSYS2.DATABASE_MONITOR_INFO — 活动和非活动的数据库性能监控器
Query Governance
查询治理
- QSYS2.QUERY_SUPERVISOR -- Query supervisor threshold rules and filters
- QSYS2.QUERY_SUPERVISOR — Query Supervisor 阈值规则和过滤器
Materialized Query Tables
物化查询表
- QSYS2.SYSMQTSTAT -- MQT refresh status, usage counts, sizes, and maintenance settings
- QSYS2.SYSMQTSTAT — MQT 刷新状态、使用次数、大小和维护设置
Key Capabilities
核心功能
Index Statistics & Optimization
索引统计与优化
- Usage tracking -- Query use count and last query use for each index
- Unused detection -- Find indexes never used by the optimizer (cleanup candidates)
- Build history -- Last build time, type (rebuild vs. incremental), and degree of parallelism
- Key analysis -- Number of key columns, column names, uniqueness, and sparseness
- 使用情况跟踪 — 每个索引的查询使用次数和最后查询使用时间
- 未使用检测 — 查找优化程序从未使用的索引(清理候选项)
- 构建历史 — 最后构建时间、类型(重建或增量)以及并行度
- 键分析 — 键列数量、列名称、唯一性和稀疏性
Maintained Temporary Index Analysis
维护型临时索引分析
- Per-table MTIs -- List all MTIs on a specific table with usage counts and sizes
- System-wide MTI overhead -- Find tables with the largest MTI footprints
- Promotion candidates -- Identify frequently-used MTIs that should become permanent indexes
- 按表分析 MTI — 列出特定表上的所有 MTI,以及使用次数和大小
- 全系统 MTI 开销 — 查找 MTI 占用空间最大的表
- 提升候选项 — 识别应转为永久索引的常用 MTI
Database Monitor Management
数据库监控器管理
- Monitor inventory -- List all database monitors with status, type, and filters
- Output tracking -- Monitor file locations, row counts, and data sizes
- Filter review -- Job, user, and SQL code filters applied to each monitor
- 监控器清单 — 列出所有数据库监控器及其状态、类型和过滤器
- 输出跟踪 — 监控器文件位置、行数和 data 大小
- 过滤器审查 — 每个监控器所应用的作业、用户和 SQL 代码过滤器
Query Supervisor
Query Supervisor
- Threshold rules -- All defined thresholds with types, values, and detection frequency
- Scope filters -- Job names, users, and subsystems targeted by each threshold
- 阈值规则 — 所有已定义阈值的类型、值和检测频率
- 范围过滤器 — 每个阈值所针对的作业名、用户和子系统
Materialized Query Table Tracking
物化查询表跟踪
- Refresh status -- Last refresh time and whether MQTs are enabled
- Usage statistics -- Query use count and statistics count per MQT
- Maintenance mode -- Immediate, deferred, or user-controlled refresh settings
- 刷新状态 — 最后刷新时间以及 MQT 是否启用
- 使用统计 — 每个 MQT 的查询使用次数和统计计数
- 维护模式 — 立即、延迟或由用户控制的刷新设置
Common Use Cases
常见使用场景
- Index audit -- Review all indexes on a table to assess coverage
- Unused index cleanup -- Find and remove indexes not used by the optimizer
- MTI promotion -- Identify MTIs that should become permanent indexes
- MTI overhead -- Find tables where MTI maintenance consumes excessive resources
- Monitor review -- Check what database monitors are running and their output
- Threshold audit -- Review query supervisor rules for appropriateness
- MQT health -- Verify MQTs are being refreshed and used by the optimizer
- 索引审计 — 审查某个表上的所有索引以评估覆盖情况
- 未使用索引清理 — 查找并删除优化程序未使用的索引
- MTI 提升 — 识别应转为永久索引的 MTI
- MTI 开销 — 查找 MTI 维护消耗过多资源的表
- 监控器审查 — 检查正在运行哪些数据库监控器及其输出
- 阈值审计 — 审查 Query Supervisor 规则是否适当
- MQT 健康状态 — 验证 MQT 是否正常刷新并被优化程序使用
Quick Examples
快速示例
View index statistics for a library
查看某个库的索引统计信息
bash
ibmi tool get_index_statistics --tools "$SKILL_DIR/tools/" --schema-filter MYLIBbash
ibmi tool get_index_statistics --tools "$SKILL_DIR/tools/" --schema-filter MYLIBFind unused indexes
查找未使用的索引
bash
ibmi tool get_unused_indexes --tools "$SKILL_DIR/tools/" --schema-filter MYLIB --unused-days 90bash
ibmi tool get_unused_indexes --tools "$SKILL_DIR/tools/" --schema-filter MYLIB --unused-days 90Check MTIs on a specific table
检查特定表上的 MTI
bash
ibmi tool get_mti_info --tools "$SKILL_DIR/tools/" --schema-name MYLIB --table-name ORDERSbash
ibmi tool get_mti_info --tools "$SKILL_DIR/tools/" --schema-name MYLIB --table-name ORDERSFind tables with high MTI overhead
查找 MTI 开销较高的表
bash
ibmi tool get_tables_with_high_mti --tools "$SKILL_DIR/tools/" --schema-filter MYLIB --min-mti-size 1048576bash
ibmi tool get_tables_with_high_mti --tools "$SKILL_DIR/tools/" --schema-filter MYLIB --min-mti-size 1048576Review query supervisor thresholds
审查 Query Supervisor 阈值
bash
ibmi tool get_query_supervisor_thresholds --tools "$SKILL_DIR/tools/"bash
ibmi tool get_query_supervisor_thresholds --tools "$SKILL_DIR/tools/"Pre-built Tools
预构建工具
The file provides 7 ready-to-use tools:
tools/database-performance.yaml| Tool | Description |
|---|---|
| Index usage, key columns, size, and build history |
| Indexes not used by the optimizer |
| Maintained Temporary Indexes on a specific table |
| Active and inactive database monitors |
| Query supervisor rules and filters |
| Materialized Query Table refresh and usage stats |
| Tables with largest MTI overhead |
bash
ibmi tool <tool_name> --tools "$SKILL_DIR/tools/" # Execute
ibmi tool <tool_name> --tools "$SKILL_DIR/tools/" --dry-run # Preview SQL
ibmi tools show <tool_name> --tools "$SKILL_DIR/tools/" # View detailstools/database-performance.yaml| 工具 | 描述 |
|---|---|
| 索引使用情况、键列、大小和构建历史 |
| 优化程序未使用的索引 |
| 特定表上的维护型临时索引 |
| 活动和非活动的数据库监控器 |
| Query Supervisor 规则和过滤器 |
| 物化查询表的刷新和使用统计 |
| MTI 开销最大的表 |
bash
ibmi tool <tool_name> --tools "$SKILL_DIR/tools/" # Execute
ibmi tool <tool_name> --tools "$SKILL_DIR/tools/" --dry-run # Preview SQL
ibmi tools show <tool_name> --tools "$SKILL_DIR/tools/" # View detailsReference Documentation
参考文档
- Database Performance Services Catalog -- Available SQL services
- Example SQL Patterns -- Working query examples
- IBM SYSINDEXSTAT -- View documentation
- IBM MTI_INFO -- Function documentation
- IBM DATABASE_MONITOR_INFO -- View documentation
- 数据库性能服务目录 — 可用的 SQL 服务
- SQL 查询模式示例 — 可实际运行的查询示例
- IBM SYSINDEXSTAT — 视图文档
- IBM MTI_INFO — 函数文档
- IBM DATABASE_MONITOR_INFO — 视图文档