Skip to content

feat(mysql): implement columnStats using INFORMATION_SCHEMA.STATISTICS#233

Open
samuelayanshina wants to merge 1 commit into
Kaelio:mainfrom
samuelayanshina:feat/mysql-column-stats
Open

feat(mysql): implement columnStats using INFORMATION_SCHEMA.STATISTICS#233
samuelayanshina wants to merge 1 commit into
Kaelio:mainfrom
samuelayanshina:feat/mysql-column-stats

Conversation

@samuelayanshina
Copy link
Copy Markdown

The MySQL connector had columnStats disabled generateColumnStatisticsQuery returned null and the capability was set to false. This PR implements column cardinality statistics for MySQL, bringing it to parity with the Postgres connector.

What changed:

  • KtxMysqlDialect.generateColumnStatisticsQuery() now queries INFORMATION_SCHEMA.STATISTICS to return index-based cardinality estimates per column
  • KtxMysqlScanConnector now has columnStats: true, getColumnStatistics(), and a working columnStats() method
  • Added MysqlStatsRow and KtxMysqlColumnStatisticsResult interfaces
  • Full test coverage added across connector.test.ts, dialect.test.ts, and the shared dialects.test.ts conformance fixture

Why INFORMATION_SCHEMA.STATISTICS:
MySQL doesn't expose a pg_stats equivalent for all columns. INFORMATION_SCHEMA.STATISTICS provides reliable cardinality estimates for indexed columns without requiring extra permissions or prior ANALYZE TABLE calls, making it the most practical approach for MySQL 5.7+.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

@samuelayanshina is attempting to deploy a commit to the Kaelio Team on Vercel.

A member of the Team first needs to authorize it.

@luca-martial
Copy link
Copy Markdown
Contributor

Thanks for the contribution @samuelayanshina - reviewing this and will get back to you soon

Enable column cardinality statistics for the MySQL connector by querying
INFORMATION_SCHEMA.STATISTICS, which provides index-based cardinality
estimates without requiring additional permissions.

- Add generateColumnStatisticsQuery() to KtxMysqlDialect
- Add getColumnStatistics() and columnStats() to KtxMysqlScanConnector
- Flip columnStats capability from false to true
- Add MysqlStatsRow and KtxMysqlColumnStatisticsResult interfaces
- Add tests for dialect query generation and connector stats retrieval
- Update dialect conformance fixture for mysql
@samuelayanshina samuelayanshina force-pushed the feat/mysql-column-stats branch from afb4a18 to 2acd711 Compare June 2, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants