DotNetNext / SqlSugar

.Net aot ORM Fastest ORM Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping
https://www.donet5.com/Home/Doc
MIT License
5.27k stars 1.33k forks source link

子树平铺查询ToChildList()/ToChildListAsync()性能优化 #1081

Closed chuck2leo closed 1 year ago

chuck2leo commented 1 year ago

ToChildList()/ToChildListAsync() Performance Improve

这是我在论坛提的issue:https://www.donet5.com/Ask/9/16746

问题分析:和ToTree()/ToTreeAsync()类似,内部使用未经优化的泛型反射递归,导致了耗时问题 解决方案:使用词典,充分运用哈希的能力。经测试,10000条数据以根节点传入,得到子树平铺结果控制在15ms上下,加上本身的查库时间,总体也在1s以内 image

Problem analysis: Similar to ToTree()/ToTreeAsync(), the internal use of unoptimized generic reflection recursion leads to time-consuming problems

Solution: Use a dictionary and make full use of the ability of hashing. According to the test, 10000 pieces of data are transferred into the root node, and the result of sub tree tiling is controlled at 15ms or less. With its own database query time, the overall result is within 1s