---
title: "mysql 5.7中关于count(*)的优化"
author: "jackyrong"
date: "2017-09-20T19:15:52Z"
tags: []
categories: ["数据库"]
slug: "mysql-5-7-count"
draft: false
lastmod: "2017-09-20T19:15:52Z"
id: 2393908
url: "https://jackyrong.iteye.com/blog/2393908"
---

在mysql 5.7中，对于select count(*) from table 的优化，可以
设置为：
select count(*) from table where uid>0
其中uid为辅助索引，辅助索引不存放数据，而是有一个指针指向对应的数据块，因此速度更快；


但注意到http://www.ywnds.com/?p=10369中提到的问题，要引起注意