Ii. Use utility objects to improve query performance [Case Study]
This is a real problem that my colleagues use utility objects to solve for a user. This user calls ao to perform a space query, and then performs paging on the basis of the query. When paging, the user traverses all ifeature values on the page, extracts attribute information, and constructs his own results to return -- results, when a serious performance problem occurs, it takes two or three minutes to query tens of thousands of records. This is intolerable in a national project.
After adding log analysis, it is found that the AO query speed is very fast. The problem is that the ifeature traversal operation is continuously produced by cross-process calls. At this time, 9.3.1 was officially released, and utility objects came as a savior!
As we have already made it clear in the previous section about how to define a utility object, we will not discuss how to encapsulate interfaces and implementation classes here. The following is the encapsulated functional code, which is mainly used to traverse the paging elements and extract useful information. Of course, the original code is executed at the web layer.
Ifeature feature = featurecursor. nextfeature ();
Int
Featurecount = 0;
While
(Feature! =Null
)
{
If
(Featurecount> = first + pagesize)
{
Break
;
}
If
(Featurecount> = first)
{
Result. Add (serviceutil. feature2einfo (feature ));
}
Featurecount ++;
Feature = featurecursor. nextfeature ();
}
After such processing, the performance has been greatly improved. A simple test can explain the situation: a space query with a radius of 1000 kilometers is conducted here, and the total number of returned results is 30437.
|
Paging start record |
Number of paging records |
Before optimization (s) |
After optimization (s) |
|
0 |
500 |
179.406 |
5.203 |
If you have fine-grained operations and have encountered performance problems, are you very excited?