mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-25 08:48:08 +02:00
feat(mysql): implement columnStats using INFORMATION_SCHEMA.STATISTICS (#233)
* feat(mysql): implement columnStats using INFORMATION_SCHEMA.STATISTICS 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 * fix(mysql): filter to leading index columns to avoid inflated cardinality Add AND SEQ_IN_INDEX = 1 to INFORMATION_SCHEMA.STATISTICS query to ensure only leading index columns are returned. For composite indexes, non-leading columns report the cardinality of the index prefix rather than the column's own distinct count, which inflates distinctCount. Add regression test asserting SEQ_IN_INDEX = 1 is present in the query. * fix: add trailing newline to dialect.test.ts --------- Co-authored-by: Andrey Avtomonov <andreybavt@gmail.com>
This commit is contained in:
parent
0d0ea55184
commit
18245c2373
5 changed files with 97 additions and 10 deletions
|
|
@ -89,7 +89,7 @@ const fixtures: DialectFixture[] = [
|
|||
cardinalityContains: 'SELECT COUNT(DISTINCT val) AS cardinality',
|
||||
randomizedCardinalityContains: 'ORDER BY RAND()',
|
||||
distinctValuesContains: 'SELECT DISTINCT CAST(`status` AS CHAR) AS val',
|
||||
statisticsContains: null,
|
||||
statisticsContains: 'INFORMATION_SCHEMA.STATISTICS',
|
||||
dimensionInput: 'tinyint(1)',
|
||||
dimensionType: 'boolean',
|
||||
nativeTypeInput: 'varchar(255)',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue