dolt: `information_schema.statistics` table is missing `cardinality` column values

Set up:

> create table t (id int primary key auto_increment, num int, index num_idx(num));
> insert into t (num) values (1),(1),(2),(4),(1);
> analyze table t;

MySQL:

mysql> select table_name, index_name, column_name, cardinality from information_schema.statistics where table_name = 't';
+------------+------------+-------------+-------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+------------+------------+-------------+-------------+
| t          | num_idx    | num         |           3 |
| t          | PRIMARY    | id          |           5 |
+------------+------------+-------------+-------------+

Dolt:

select table_name, index_name, column_name, cardinality from information_schema.statistics where table_name = 't';
+------------+------------+-------------+-------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+------------+------------+-------------+-------------+
| t          | PRIMARY    | id          | 0           |
| t          | num_idx    | num         | 0           |
+------------+------------+-------------+-------------+

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 34 (14 by maintainers)

Most upvoted comments

This, https://github.com/dolthub/go-mysql-server/blob/main/sql/information_schema/information_schema.go#L1359 is where the STATISTICS table is populated. I would say getting cardinality should be somewhat similar to getting row count of a table. This, https://github.com/dolthub/go-mysql-server/blob/main/sql/statistics.go#L24 might be where I would start looking into for implementing the getting-cardinality functionality.

@jennifersp Thanks for the info!! Could you please assign to me. 😃