We identified the issue using JetBrains dotTrace in the DevArt BuildQuery method, which takes almost 200 milliseconds to complete:
Code: Select all
22,26 % AuxGetHelper - 181,66 ms - 1 call - Jumbo.MVC.Models.ReadOnlyTableData.AuxGetHelper(IQueryable, Object)
22,20 % SingleOrDefault - 181,18 ms - 1 call - System.Linq.Queryable.SingleOrDefault(IQueryable, Expression>)
22,19 % Execute - 181,06 ms - 1 call - Devart.Data.Linq.DataQuery.Execute(Expression) (from System.Linq.IQueryProvider)
22,19 % Execute - 181,06 ms - 1 call - Devart.Data.Linq.Provider.DataProvider.Execute(Expression) (from Devart.Data.Linq.Provider.IProvider)
21,27 % BuildQuery - 173,56 ms - 1 call - Devart.Data.Linq.Provider.DataProvider.BuildQuery(Expression)
17,50 % DataProvider.CompiledQuery..ctor - 142,80 ms - 1 call - Devart.Data.Linq.Provider.DataProvider.CompiledQuery..ctor(QueryInfo, IDataServices, Boolean, Object)
17,50 % GetReaderFactory - 142,80 ms - 1 call - Devart.Data.Linq.Provider.DataProvider.CompiledQuery.GetReaderFactory(List, IDataServices, SqlNode)
17,49 % a - 142,70 ms - 1 call - Devart.Data.Linq.Provider.n.a(Type, SqlExpression, IDataServices, Type, Type)
0,01 % c - 0,09 ms - 1 call - Devart.Data.Linq.t.c(MetaType)
3,13 % i - 25,54 ms - 1 call - Devart.Data.Linq.Provider.Query.u.i(Expression)
0,27 % BuildQuery - 2,20 ms - 1 call - Devart.Data.Linq.Provider.DataProvider.BuildQuery(ResultShape, Type, SqlNode, IList)
0,21 % GetCompiledQueryFromCacheWithLock - 1,73 ms - 1 call - Devart.Data.Linq.Provider.DataProvider.GetCompiledQueryFromCacheWithLock(Expression, CompiledQueryCache &, a &)
0,16 % a - 1,27 ms - 1 call - Devart.Data.Linq.Provider.Query.ae.a(Expression)
0,92 % ExecuteAllQueries - 7,49 ms - 1 call - Devart.Data.Linq.Provider.DataProvider.ExecuteAllQueries(CompiledQuery, Object [])
0,01 % Cast - 0,11 ms - 1 call - System.Linq.Queryable.Cast(IQueryable)
Code: Select all
22,26 % AuxGetHelper - 181,66 ms - 1 call
22,20 % SingleOrDefault - 181,18 ms - 1 call
22,19 % Execute - 181,06 ms - 1 call
22,19 % Execute - 181,06 ms - 1 call
21,27 % BuildQuery - 173,56 ms - 1 call
17,50 % DataProvider.CompiledQuery..ctor - 142,80 ms - 1 call
17,50 % GetReaderFactory - 142,80 ms - 1 call
17,49 % a - 142,70 ms - 1 call
0,01 % c - 0,09 ms - 1 call
3,13 % i - 25,54 ms - 1 call
0,27 % BuildQuery - 2,20 ms - 1 call
0,21 % GetCompiledQueryFromCacheWithLock - 1,73 ms - 1 call
0,16 % a - 1,27 ms - 1 call
0,92 % ExecuteAllQueries - 7,49 ms - 1 call
0,01 % Cast - 0,11 ms - 1 call
Maybe this is because we aren't using the caching correctly (the above GetCompiledQueryFromCacheWithLock suggests the BuildQuery's actions are cached).
Our code is as follows:
Code: Select all
///
/// Auxillary method for Get / GetDirectFromTable
///
///
///
///
private TModelClass AuxGetHelper(IQueryable query, object id)
{
if (id == null)
return null;
return (TModelClass)query.Cast().SingleOrDefault(record => record.Id == (long)id);
}
Is it possible to speed this up?
Kind regards,
Edwin.