Computing.Net > Forums > Programming > 100% CPU Utilization- excel to sql

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

100% CPU Utilization- excel to sql

Reply to Message Icon

Name: jbellan
Date: December 13, 2007 at 08:02:23 Pacific
OS: windows 2003 server
CPU/Ram: 2 gb
Comment:

Problem: 100% CPU utilization
Application: Windows Application (.NET 2.0, C#, SQL SERVER 2005, Web Services).
Purpose: To upload data from an excel sheet to the database
Functionality:
The excel sheet will have around 15,000 – 100,000 rows of data across 40 – 50 columns.

The data from the excel sheet has to be imported into three Tables in the database which includes certain business logic.

Constraints: We are not supposed to use database objects like Stored Procedures or DTS packages due to portability issues.

The data upload process done by the application is explained below.
1. The excel data is populated into a Data Table using the excel manager. The data tables in the dataset is then populated from this excel data table and finally the table adapters update method is called to push the data from the dataset to the database.
2. For this import process we also need to check if the data in the excel sheet already exists in the database. For doing this validity we tried two different approaches.
a. The existing data from the database for the particular item is populated in the data table. For example the "Data Table 1" data table is populated from the database initially. Then the process runs in a loop for each row in the excel data table and checks if the data is existing in the "Data Table 1" data table and adds the new row if the data doesn’t exist. After updating the "Data Table 1" data table the table adapters update method is called to push the data to the database. A similar process is carried out for updating the other two data tables also in the dataset.
This process causes a 100% CPU utilization on the web service.

b. The second approach was to eliminate the process of validating for existing records in the data tables. For example all the "Data Table 1" data from the excel data table was inserted into the "Data Table 1" data table. The table adapters update method was called and the validation for existing records was carried out in the database side. The command text for the insert command was updated appropriately like “IF NOT EXISTS (SELECT ….) INSERT INTO ….”
This process caused a 100% CPU utilization on the database server.

Is there any better approach that can minimize the CPU Utilization or any configuration settings that needs to be looked at.

Any help will be appreciated. Thanks.




Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: December 13, 2007 at 13:39:51 Pacific
Reply:

Maybe I'm missing something, but why don't you rely on your Primary Key to do its job, and just insert the data straight into the database? The biggest complication I see from this is a Primary Key Not Unique error, which is easily ignored.


0

Response Number 2
Name: jbellan
Date: December 14, 2007 at 01:14:52 Pacific
Reply:

Thanks Razor.
Yes we do insert data to the database from the dataset by using the update method of the tableadapter in one of the approaches. We validate for uniqueness for a couple of columns other than the Primary Key which is an IDENTITY column in the database. This is the process which uses max cpu because of its intensity.

Can this be handled in a different approach other than Datasets, or if this has something to do with the server configuration as well.


0

Response Number 3
Name: Razor2.3
Date: December 14, 2007 at 02:25:40 Pacific
Reply:

Well, I guess you could build your own index, and then refer to that during your uniqueness checks. I'm not sure how much this would save you, though, but it's bound to be faster than your brute force method. It'd depend on the amount of data you're checking against. A second option would be to split the uniqueness checks and the database INSERTs into two separate threads. Depending on how you implemented it, the program might become IO (database) bound.


0

Response Number 4
Name: jbellan
Date: December 14, 2007 at 03:48:17 Pacific
Reply:

The uniqueness check needs to be done for data of about 15000 to 100000 which is going to be slow.

The second option you have mentioned about spliting the process into separate threads seems something we may want to try out.
Thanks for the suggestions.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: 100% CPU Utilization- excel to sql

XML mapping to SQL www.computing.net/answers/programming/xml-mapping-to-sql/11159.html

Convert File Maker to SQL Database www.computing.net/answers/programming/convert-file-maker-to-sql-database/8979.html

Connecting to sql database code www.computing.net/answers/programming/connecting-to-sql-database-code/14462.html