有分表策略的表,不方便在构造函数中查找Count,因为此时尚未确定分表目标

This commit is contained in:
智能大石头 2025-07-30 19:01:25 +08:00
parent e2f76c5cf2
commit 69444a58b9
1 changed files with 6 additions and 3 deletions

View File

@ -45,9 +45,12 @@ public partial class ReadOnlyEntityController<TEntity>
set.EnableTableDoubleClick = CubeSetting.Current.EnableTableDoubleClick;
#endif
// 大于100万条数据时默认不启用数字型主键降序避免数据库选择主键索引导致复杂查询变慢
if (set.OrderByKey && Entity<TEntity>.Meta.Count > 1_000_000)
set.OrderByKey = false;
if (set.OrderByKey)
{
// 大于100万条数据时默认不启用数字型主键降序避免数据库选择主键索引导致复杂查询变慢
if (Entity<TEntity>.Meta.ShardPolicy == null && Entity<TEntity>.Meta.Count > 1_000_000)
set.OrderByKey = false;
}
SysConfig = SysConfig.Current;
}