简体   繁体   中英

Process performance over SQL Server

I have a time-consuming process that iterates a collection of items (eg 3500), where I need to query a database (currently using SQL Server) for each item (in fact very simple query).

I'm doing the queries one by one (in the loop) instead of an only batch query at the beggining, because the DAO has been given and I'm not able to change it at this moment.

The problem that I'm facing is that, if this process takes 2 minutes, 1'55" of them belongs to database accesses ... and "only" 5" for the hard work. I'm creating an only connection (at the beginning) instead of creating 3500 connections (too much payload), and also I tried to create a transaction at the beginning ... but it takes the same.

My question is: Is there any way to improve the performance of those queries, one by one, without reimplementing the DAL in order to do a batch query?

Attaching a pic of the SQL Server profiler:

SQL Server分析器图片

Thanks in advance.

The duration of those queries is ~0ms. You cannot improve this, no matter what the query is.

You should find out why 3500 0ms queries take 2min. That is far too long. Maybe the time is spent elsewhere or on the network.

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