mysql - 为什么使用Group By对SQL的索引性能会有很大的影响
问题描述
为什么使用Group By对SQL的索引性能会有很大的影响?索引是不是能提升group by的性能?
还有一点关于SQL的疑问,为什么在使用模糊查询的时候,%name%, 如果使用了前模糊,会使得索引没有了效果,这个怎么理解,虽然模糊的知道可能是这样的,但是找不到官方对此的说法。谢谢~
问题解答
回答1:“对索引性能有很大影响”是指什么?索引的时间太久了?但这似乎又和gruop by没什么关系。
所以我猜你的问题是不是“索引是不是能提升group by的性能”?这个问题的因果关系好想更容易理解些,那如果是这个问题的话,可能下面这段话能给你一些提示:
SQL databases use two entirely different group by algorithms. Thefirst one, the hash algorithm, aggregates the input records in atemporary hash table. Once all input records are processed, the hashtable is returned as the result. The second algorithm, the sort/groupalgorithm, first sorts the input data by the grouping key so that therows of each group follow each other in immediate succession.Afterwards, the database just needs to aggregate them. In general,both algorithms need to materialize an intermediate state, so they arenot executed in a pipelined manner. Nevertheless the sort/groupalgorithm can use an index to avoid the sort operation, thus enablinga pipelined group by.
原文出处:Indexing Group By
相关文章:
1. mysql - 分库分表、分区、读写分离 这些都是用在什么场景下 ,会带来哪些效率或者其他方面的好处2. javascript - ios返回不执行js怎么解决?3. python - 爬虫模拟登录后,爬取csdn后台文章列表遇到的问题4. 视频文件不能播放,怎么办?5. python bottle跑起来以后,定时执行的任务为什么每次都重复(多)执行一次?6. html5 - HTML代码中的文字乱码是怎么回事?7. javascript - 求帮助 , ATOM不显示界面!!!!8. mysql 查询身份证号字段值有效的数据9. javascript - angular使从elastichearch中取出的文本高亮显示,如图所示10. javascript - 为什么在谷歌控制台 输出1的时候,输出的1立马就不见了
