Update ExtensionMethods.cs
This commit is contained in:
@@ -147,7 +147,27 @@ namespace Duplicati.Library.Main.Database
|
||||
con.Transaction = transaction;
|
||||
return con;
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Small helper method querying and returning a textual representation of the SQLite execution plan. </summary>
|
||||
public static string GetSQLiteExecutionPlan(this System.Data.IDbCommand cmd)
|
||||
{
|
||||
var qpCmd = cmd.Connection.CreateCommand();
|
||||
qpCmd.CommandText = "EXPLAIN QUERY PLAN " + cmd.CommandText;
|
||||
qpCmd.Connection = cmd.Connection;
|
||||
qpCmd.CommandType = cmd.CommandType;
|
||||
qpCmd.Transaction = cmd.Transaction;
|
||||
|
||||
System.Data.DataTable dt = new System.Data.DataTable();
|
||||
using (var rd = qpCmd.ExecuteReader())
|
||||
dt.Load(rd);
|
||||
|
||||
string plan =
|
||||
String.Join("\t", dt.Columns.Cast<System.Data.DataColumn>().Select(c => c.ColumnName).ToArray()) + "\n"
|
||||
+ string.Join("\n", dt.Rows.Cast<System.Data.DataRow>().Select(r => String.Join("\t", r.ItemArray.Select(o => o == null ? "" : o.ToString()).ToArray())).ToArray());
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
public static void DumpSQL(this System.Data.IDbConnection self, System.Data.IDbTransaction trans, string sql, params object[] parameters)
|
||||
{
|
||||
using (var c = self.CreateCommand())
|
||||
|
||||
Reference in New Issue
Block a user