mysql - 为什么使用Group By对SQL的索引性能会有很大的影响
天蓬老师
天蓬老师 2017-04-17 14:51:32
0
1
640

为什么使用Group By对SQL的索引性能会有很大的影响?索引是不是能提升group by的性能?


还有一点关于SQL的疑问,为什么在使用模糊查询的时候,%name%, 如果使用了前模糊,会使得索引没有了效果,这个怎么理解,虽然模糊的知道可能是这样的,但是找不到官方对此的说法。谢谢~

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回覆(1)
巴扎黑

「對索引效能有很大影響」是指什麼?索引的時間太久了?但這似乎又跟gruop by沒什麼關係。

所以我猜你的問題是不是「索引是不是能提升group by的效能」?這個問題的因果關係好想更容易理解些,那如果是這個問題的話,可能下面這段話能給你一些提示:

SQL databases use two entirely different group by algorithms. The
first one, the hash algorithm, aggregates the input records in a
temporary hash table. Once hash table. 🎜>table is returned as the result. The second algorithm, the sort/group
algorithm, first sorts the input data by the grouping key so that the
rows of each data follow group al. >Afterwards, the database just needs to aggregate them. In general,
both algorithms need to materialize an intermediate state, so they are
not executed in a pipelined manner. Nevertheless the sort/gorTm an index to avoid the sort operation, thus enabling
a pipelined group by.


原文出處:Indexing Group By

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!