使用索引进行MySQL查询优化

时间:2014-01-20 15:29:09

标签: mysql sql query-optimization

我的邮政编码表有超过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列的记录具有相同的值。只是想让你知道,以防万一。

感谢。

0 个答案:

没有答案