MySQL 如何查询重复次数大于 N 的数据的个数
select name, count(name) as c from table_name group by name having c > N;
在name上面做索引
explain一下大概就是
+—-+————-+——-+——-+—————+———-+———+——+——+————-+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+—-+————-+——-+——-+—————+———-+———+——+——+————-+
| 1 | SIMPLE | test | index | NULL | id_index | 4 | NULL | 9 | Using index |