为什么使用Group By对SQL的索引性能会有很大的影响

发布于 2022-09-02 20:08:55 字数 164 浏览 17 评论 0

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


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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云裳 2022-09-09 20:08:55

“对索引性能有很大影响”是指什么?索引的时间太久了?但这似乎又和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 all input records are processed, the hash
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 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 are
not executed in a pipelined manner. Nevertheless the sort/group
algorithm can use an index to avoid the sort operation, thus enabling
a pipelined group by.

原文出处:Indexing Group By

半寸时光 2022-09-09 20:08:55

我只知道group by与索引的前后顺序,索引要在group by前面

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文