Hello to all,
my application, use web project, XAF Framework 20.1.7.
I have unexpected behavior of the AUDIT module, especially the time it took to insert the record.
Currently I have this amount of records in the tables related to the AUDIT (AuditTrail)(abaut 5 milion record):
SQLSELECT count(*) FROM [EAMS_OL_SL].[dbo].[AuditDataItemPersistent] -- 5.053.084
SELECT count(*) FROM [EAMS_OL_SL]. [dbo].[AuditedObjectWeakReference] -- 465.889
SELECT count(*) FROM [EAMS_OL_SL]. [dbo].[XPWeakReference]-- 2.954.143
I did this test (for one record):
A) In the case of the aforementioned record quantity: the time to insert this record is 3-4 seconds (for one record);
C#using (UnitOfWork UW = Helpers.XpoHelperAudit.GetNewUnitOfWork())
{
//AuditTrailService.Instance.BeginSessionAudit(UW, AuditTrailStrategy.OnObjectChanged);
//*******************************************************************************************
..........
........
if (vIEPlantList != null)
{
XPQuery<IEValueList> qIEValueList = new XPQuery<IEValueList>(UW);
int cont = qIEValueList.Where(w => w.IEPlantList.Oid == vIEPlantList.Oid && w.DataValueString == Datacsv).Count();
//&& w.DataValue > dataValore.AddMinutes(-1) && w.DataValue < dataValore.AddMinutes(1) ).Count();
if (cont == 0) /// se il valore non e' stato già inserito
{
//Console.WriteLine("file csv: Value of i:{0} - {1} {2}", riga, Datacsv, Valorecsv);
Console.WriteLine(" file csv:{0} Riga:{1}, Data:{2}, Valore:{3}", PathFileName, riga, Datacsv, Valorecsv);
/// carico la lista dei valori
IEValueList myNewIEValueList = new IEValueList(UW);
//myNewIEValueList.DataValue = dataValore;
myNewIEValueList.DataValueString = Datacsv;
myNewIEValueList.Value = Valorecsv;
myNewIEValueList.IEPlantList = vIEPlantList;
myNewIEValueList.DataAggiornamento = DateTime.Now;
myNewIEValueList.Descrizione = string.Format("File Import: {0}", worksheet.Name);
myNewIEValueList.Save();
UW.CommitChanges();
}
else
{
Console.WriteLine("valore già inserito, file csv:{0} Riga:{1}, Data:{2}, Valore:{3}", PathFileName, riga, Datacsv, Valorecsv);
myLogger.writeTestLog(string.Format("valore già inserito, file {0} riga {1}, Applicazione {2}", PathFileName, riga, pApplicazione));
}
}
//*******************************************************************************************
Console.WriteLine(" file DateTime.Now):{0} ", DateTime.Now);
//AuditTrailService.Instance.QueryCurrentUserName += OnAuditTrailServiceInstanceQueryCurrentUserName;
//AuditTrailService.Instance.SaveAuditData(UW);
//AuditTrailService.Instance.QueryCurrentUserName -= OnAuditTrailServiceInstanceQueryCurrentUserName;
Console.WriteLine(" file DateTime.Now):{0}", DateTime.Now);
}
B) In the case of the REDUCED record quantity, I have deleted 90% of the records and the time to insert this record is less than one second (same code as above);
it does not seem to me (from my knowledge) that the insertion time of the records in the table, from the point of view of the t-sql code, varies in this way according to the records count in the table.
so I assume that the "AuditTrail" module executes queries before / after inserting records on the "AuditDataItemPersistent" table.
if so, perhaps an index to be created is missing or the insertion procedure could be improved.
I await your clarification.
Hello Andrea,
We need to review SQL profiler logs before we research this issue. Would you please record SQL queries when inserting a problematic audit record? To record SQL queries, use dedicated tools shipped with the database or the XPO Profiler tool installed with DevExpress components.
We look forward to hearing from you.
Monday 28th we will send you the sql
Hello Andrea,
This time may vary a lot based on record count without ongoing database maintenance. You may find the following articles helpful:
Hello ,
Adding XPWeakReference table Index helped a lot with speed, it works fast now.
Thanks.
@Murat YONAR: Thank you for sharing!