NewLife/X

Oracle异步更新统计信息,屏蔽错误
大石头 authored at 2017-08-04 13:18:42
a6f4992
Tree
1 Parent(s) 7fa5391
Summary: 2 changed files with 15 additions and 4 deletions.
Modified +1 -1
Modified +14 -3
Modified +1 -1
diff --git a/NewLife.Core/Reflection/AssemblyX.cs b/NewLife.Core/Reflection/AssemblyX.cs
index 388d440..8ccc515 100644
--- a/NewLife.Core/Reflection/AssemblyX.cs
+++ b/NewLife.Core/Reflection/AssemblyX.cs
@@ -133,7 +133,7 @@ namespace NewLife.Reflection
 #if !__MOBILE__ && !__CORE__
             AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += (sender, args) =>
             {
-                XTrace.WriteLine("[{0}]请求只反射加载[{1}]", args.RequestingAssembly?.FullName, args.Name);
+                if (XTrace.Debug) XTrace.WriteLine("[{0}]请求只反射加载[{1}]", args.RequestingAssembly?.FullName, args.Name);
                 return Assembly.ReflectionOnlyLoad(args.Name);
             };
 #endif
Modified +14 -3
diff --git a/XCode/DataAccessLayer/Database/Oracle.cs b/XCode/DataAccessLayer/Database/Oracle.cs
index 2af1623..31f7dd5 100644
--- a/XCode/DataAccessLayer/Database/Oracle.cs
+++ b/XCode/DataAccessLayer/Database/Oracle.cs
@@ -6,6 +6,7 @@ using System.IO;
 using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
+using System.Threading.Tasks;
 using XCode.Common;
 
 namespace XCode.DataAccessLayer
@@ -352,10 +353,20 @@ namespace XCode.DataAccessLayer
             tableName = tableName.ToUpper();
             var owner = (Database as Oracle).Owner.ToUpper();
 
-            String sql = String.Format("analyze table {0}.{1}  compute statistics", owner, tableName);
-            if ((Database as Oracle).NeedAnalyzeStatistics(tableName)) Execute(sql);
+            if ((Database as Oracle).NeedAnalyzeStatistics(tableName))
+            {
+                // 异步更新,屏蔽错误
+                Task.Run(() =>
+                {
+                    try
+                    {
+                        Execute("analyze table {0}.{1} compute statistics".F(owner, tableName));
+                    }
+                    catch { }
+                });
+            }
 
-            sql = String.Format("select NUM_ROWS from sys.all_indexes where TABLE_OWNER='{0}' and TABLE_NAME='{1}' and UNIQUENESS='UNIQUE'", owner, tableName);
+            var sql = String.Format("select NUM_ROWS from sys.all_indexes where TABLE_OWNER='{0}' and TABLE_NAME='{1}' and UNIQUENESS='UNIQUE'", owner, tableName);
             return ExecuteScalar<Int64>(sql);
         }