mysql 生成实体类 获取系统表,列数据sql性能差,需要优化 返回
C#论坛
老数据
6
1599
悬赏:5 飞吻
我这里正式环境废弃之后用来做测试环境了。
mysql 数据库,有40个schema ,每个schema 里面有大概有400张表。
这40个schema 都包含同一张表bas_codetype ,然后生成就卡死了。
最后
.NullReferenceException: SqlSugar.AdoProvider.GetDataReader(, SugarParameter[] parameters) SqlSugar.AdoProvider.SqlQuery[T,T2,T3,T4,T5,T6,T7](, Object parameters) SqlSugar.AdoProvider.SqlQuery[T](, SugarParameter[] parameters) SqlSugar.AdoProvider.SqlQuery[T](, Object parameters) SqlSugar.DbMaintenanceProvider.<>c__DisplayClass43_0`1.<GetListOrCache>b__0() SqlSugar.ReflectionInoCore`1.GetOrCreate(cacheKey, Func`1 create) SqlSugar.ReflectionInoCacheService.GetOrCreate[V](String cacheKey, Func`1 , Int32 cacheDurationInSeconds) SqlSugar.DbMaintenanceProvider.GetListOrCache[T](cacheKey, ) SqlSugar.DbMaintenanceProvider.GetTableInfoList(isCache) SqlSugar.DbFirstProvider.Init() SqlSugar.SqlSugarProvider.get_DbFirst() SqlSugar.SqlSugarClient.get_DbFirst() MysqlDemo.FormMysqlSugarTest.btnClickTest_Click(Object sender, EventArgs e) G:\net\ORM\sqlSugar\4.x\MysqlDemo\MysqlDemo\FormMysqlSugarTest.cs:.Windows.Forms.Control.OnClick(EventArgs e) .Windows.Forms.Button.OnClick(EventArgs e) .Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) .Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) .Windows.Forms.Control.WndProc(Message& m) .Windows.Forms.ButtonBase.WndProc(Message& m) .Windows.Forms.Button.WndProc(Message& m) .Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) .Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) .Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) .Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) .Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) .Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext ) .Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext ) .Windows.Forms.Application.Run(Form mainForm) MysqlDemo.Program.Main() G:\net\ORM\sqlSugar\4.x\MysqlDemo\MysqlDemo\Program.cs:
已跟踪源码,会死在 这里

这个语句性能太差了,需要优化。麻烦升级项目。
热忱回答(6)
-
fate stay night VIP0
2021/3/23这个比较难优化,你有1600个表
0 回复 -
fate stay night VIP0
2021/3/2399% 用户几百个表都没问题
0 回复 -
Liam yang VIP0
2021/3/23@fate stay night:你这个CheckSession的sql不是在 mysql 实现类里面重写的? 如果仅确认是否有系统表的权限,可以替换一下 sql 是否OK ?
select 1 from information_schema.COLUMNS a where 1=1 and TABLE_SCHEMA='mysql' and TABLE_NAME='user' limit 1;
比如我我修改成这个语句 OK?
0 回复 -
fate stay night VIP0
2021/3/23这样不行,不同用户会出现很多问题
0 回复 -
fate stay night VIP0
2021/3/23你可以特殊项目改个源码先用用
0 回复 -
Liam yang VIP0
2021/3/23@fate stay night:我觉得,加个条件和你不加条件 对切换用户是等同的。
索性加个条件,性能就上去了。
无论你加不加条件,如果当前操作数据库的用户没有权限,都读取不到。
0 回复