简体   繁体   中英

Measuring number of database calls per http request

Recently, our company is focusing on performance of the application we are developing for long time. One thing we noticed during performance test, certain methods are making so many database calls (over 500 queries)

Then this brings a question like, which methods are doing so many calls and how should be prioritize which method to refactor first. When we initially try to refactor some of those methods, we observed that it is requiring a lot of effort to reduce the number of round-trips. The reason is our data access layer is pretty much depending on NHibernate ORM framework and we figured out that we have totally misused Lazyloading configuration from the beginning of the development. That is why number of round-trips are huge and impacting the performance a lot. And just correcting Lazy Loading configuration creates a lot of regression.

Thus, we somehow have to figure out a way to collect number of database call per http request. I have seen some tools like Application Insight or AppDynamics provides overall result for all Dependent calls. But I am just wondering is there a way to collect these traces differently than using those frameworks ?

For instance, every time http request is made, can we have attribute in the controller that whenever ExecuteQuery() or SqlDataAdapter.Fill method is called within the call stack of the method, can it increase the counter. I am looking for a solution something like this.

Any help is greatly appreciated.

Thank you in advance for all suggestions.

Use Stackify Prefix for this kind of things:

https://stackify.com/prefix/

View SQL queries: Including SQL parameters, affected records and how long it took to download the result set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM