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.
「對索引效能有很大影響」是指什麼?索引的時間太久了?但這似乎又跟
gruop by
沒什麼關係。所以我猜你的問題是不是「索引是不是能提升group by的效能」?這個問題的因果關係好想更容易理解些,那如果是這個問題的話,可能下面這段話能給你一些提示: