I have an application in MVC 4 that has no addition / deletion / editing operation, it only reads and makes data available (according to filters).
The data comes basically from 4 views .
- Being the first of about 1,500 records - instant reading via query
- The second of about 15 thousand - reading about 14 seconds via query
- The third of about 30 records - instant read via query
- The fourth of about 1.3 thousand records - instant read via query
Each view
has its own model. Consecutively, in every% required%, I call the required domain.
I previously worked similarly to this example:
var bdModelA = new SegundaViewEF(Contexto); // View da query de 14 segundos
var Todos = bdModelA.ListarTodos();
var Quantidade = Todos.Count();
var NF = Todos.Where(x => x.Tipo == "NF");
var NCC = Todos.Where(x => x.Tipo == "NCC");
var QuantidadeNF = NF.Count();
var QuantidadeNCC = NCC.Count();
foreach(var Item in NF){
// codigo aqui
}
foreach(var Item in NCC){
// codigo aqui
}
I noticed slow, I started working like this:
var bdModelA = new SegundaViewEF(Contexto);
var Todos = bdModelA.ListarTodos();
var QuantidadeNF = 0;
var QuantidadeNCC = 0;
var Quantidade = 0;
foreach(var Item in Todos){
Quantidade++;
if(Tipo == "NF"){
QuantidadeNF++;
//Codigo aqui
}else if(Tipo =="NCC"){
QuantidadeNCC++;
//Codigo aqui
}
}
It was slow.
I would like to know if the best practice is the one described in the first example or the second and if there is any limitation of the MVC with respect to reading PartialView
, since I always worked with table reading.
I call one of three different domains in each of my PartialViews, the one of the largest query (14 seconds), I call at least 4 times. I have about 7 to 8 PartialView.
My application takes about 8 minutes to open (VPN connection) and 5 minutes via direct connection.
What can I do to improve?