Solved

Multiple CPUs - SQL2005 - Windows 2003 - VB.net

Posted on 2007-03-30
6
223 Views
Last Modified: 2013-12-10
We are developing a VB.net application against the SQL2005 / Windows 2003 server (4 CPUs), when we run the application which has heavily sql queries, the CPU performance of the SQL server only see one CPU at a time being pegged at 100%, while others are pretty much quiet, but the 100% peak takes turns from one CPU to the other. My question is that:
1) how is it possible to have the CPU usage be evenly spread between the 4 CPUs?
2) why I see 8 CPU instants in Windows Performance task manager other than 4?
3) Is the OS, SQL or App. itself controlling the CPU ultilization?

Thanks,
fshguo.
0
Comment
Question by:fshguo
  • 3
  • 2
6 Comments
 
LVL 18

Assisted Solution

by:DarrenD
DarrenD earned 100 total points
ID: 18823219
Hi,

You can tell SQL Server how many CPU's to use so it could be just set to one.

You have to buy a licence per processor though under certain licence agreements.

If you right click on the SQL Server in Microsoft SQL Server Management Server and choose properties you can then select processors and see how many are being used

Darren
0
 
LVL 21

Assisted Solution

by:mastoo
mastoo earned 400 total points
ID: 18824657
After checking what DarrenD describes...

If you are running a single, single threaded app against Sql Server most activity will take place on a single processor.  In isolated cases, sql server might optimize a query by spreading it across more than one processor but that would be the exception rather than the general rule.  If your app is threaded or multiple instances run, they can be submitting multiple concurrent queries which will then cause more than one cpu to be used.

You'll see 8 if you have 4 processors that either are dual core or support hyperthreading.
0
 

Author Comment

by:fshguo
ID: 18824850
I checked the SQL server can see 8 processors. and yes, it is dual core.

Now my question to Mastoo is that how can we make the change so that the App is multiple threaded?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 21

Accepted Solution

by:
mastoo earned 400 total points
ID: 18824964
Multi-threaded programming is complicated and I can't do the subject justice here.  Can I suggest a couple other things before you go that route?  They all have potential for boosting performance enough that you might not feel the need to thread your app.

#1.  If you're going to have several people running your app at the same time, in effect this is the same as threading since it means your database server will be running several queries at the same time.  In this case, threading would help a single person but when several people run the performance would be unchanged.

#2. Use a code profiler on your app to be sure it spends most of its time waiting on the database.  If it only spends 20% of its time waiting on the db, and you thread it to cut that in half, you've only boosted your performance by 10%.

#3. If your app is waiting on the db for most of the time, use sql profiler to identify the queries that take the longest and then optimize those queries.  A simple index change can have a dramatic effect on performance.

#4. If none of those help, then look at the SqlCommand methods like BeginExecuteReader and BeginExecuteNonQuery.  Those are the easiest ways to thread things when db performance is the bottleneck.  They limit the scope of the threading.  They make coding a little more difficult because code needs to start several queries (loading up multiple cpus) and then react when they queries finish.  If you're using databound controls, threading isn't an option.
0
 

Author Comment

by:fshguo
ID: 18826056
Thanks Wastoo, how code profiler knows how long it is spending waiting for database? simply a URL link will be helpful.  

0
 
LVL 21

Expert Comment

by:mastoo
ID: 18826206
I use ants:

http://www.red-gate.com/products/ants_profiler/index.htm

Basically you run your program under the profiler.  When done, it will show you what percent of the total time was spent in what functions.  This lets you quickly identify where your code spends most of its time so you can focus on fixing the right chunk of code.  For example I might see that a button click takes 5 seconds, and of that time 25% is in a couple of database calls and the remaining time is spent populating a listview control.  In your case, if it leads to a couple stored procedure calls you'd know which procs you should try to optimize.

They let you download an eval copy for a trial period so you can give it a shot.

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
On Beyond Tools A conversation I recently had with the DevOps manager of a major online retailer really made me think about DevOps monitoring tools (https://www.onpage.com/devops-incident-management-tool/). The manager and I discussed how sever…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question