0

I have an index on a table in MySQL:

| Table | Non_unique | Key_name      | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+-------+------------+---------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| 2011  |          1 | ix_2011_index |            1 | index       | A         |      292691 |     NULL |   NULL | YES  | BTREE      |         |               | YES     | NULL

When I try to see how many rows there are in the table,

SELECT COUNT(*) from mytable.2011;

It takes forever. Granted, there are tens of millions of rows in the table, but each row is indexed.

Shouldn't this be almost instantaneous?

I created the table with the default engine:

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci 
Ivan
  • 7,448
  • 14
  • 69
  • 134

0 Answers0