我的邮政编码表有超过150k的记录。
当我运行此查询时
select count(*) as total_count from pincodes where pincode = '834009';
我在慢查询日志中获得了以下统计信息。
SET timestamp=1390221731;
select count(*) as total_count from pincodes where pincode = '834009';
# Query_time: 12.261122 Lock_time: 0.000067 Rows_sent: 1 Rows_examined: 154727
我可以使用索引对其进行优化吗?我的索引应该是什么样的?或者优化此查询的任何其他方式?
修改:pincode
列的记录具有相同的值。只是想让你知道,以防万一。
感谢。