最近在做查询优化的工作。 当我尝试用多协程协助查询的时候,每个协程得到结果的速度随着协程数量增加而增加。 于是我进行了如下测试。 原生sql执行的时间为600ms。 开启多个不同数量的协程跑同样的sql。 下面是测试数据,1,600ms,2,621ms,3,699ms,4,736ms,5,878ms,6,1077ms,可以看到随着协程数的增加越来越慢。 测试代码大体结构

var wg for ... { wg.add() go func(){ 开始定时点 查询逻辑 打印查询所耗时间 wg.Done() } }

我比较关心这个问题出现的原因,还有我可以怎么做,来解决目前的问题。

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking