Link to home
Start Free TrialLog in
Avatar of Eprs_Admin
Eprs_AdminFlag for Austria

asked on

sql performance

Hi Experts,

i have an SQL 2008 cluster in my network and the user tell me a very bad performance.
Sometimes they wait 5 minutes to finish a task.

Can you help me and guide me to find these performance killers ?
SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is an  easy script I usually run to check for long running queries and blocking processes:

select	
  session_id
, start_time
, command
, sql_text.text as sql_text
, DB_NAME(database_id) as databaseName
, blocking_session_id
, user_name(user_id)		as	userName
, cpu_time
, query_hash
 

from	sys.dm_exec_requests

outer apply sys.dm_exec_sql_text(sql_handle) sql_text

order by cpu_time desc

Open in new window


Good luck.
Avatar of Eprs_Admin

ASKER

Hello,

I have installed the Performance Dashboard.
Here I can see over 70 locks and a lot of parallelism.

Can you explain the parallelism problem please ?
Parallelism can be explicit (you set it in the query with MAXDOP option) or implicit (the engine will decide to use it or not depending on the conditions) and it's used to split a query execution in many task as existing CPU/core or as many is set by the MAXDOP option.
When well used it can be a perform boost but in the other hand can be a big bottleneck if you use it wrong.

To verify the MAXDOP configured in the SQL Server instance run the following in a New Query window:
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'max degree of parallelism',
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'show advanced options', 0;
GO
RECONFIGURE WITH OVERRIDE;

Open in new window


Can't help you more without seeing the query and the respective query plan.
the script comes with an error:

Meldung 102, Ebene 15, Status 1, Zeile 1 - this is german sorry.

But it says ,ther eis an error near the comma (,)
It's right. Was a typo. Here the correct code without the extra comma:
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'max degree of parallelism'
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'show advanced options', 0;
GO
RECONFIGURE WITH OVERRIDE;

Open in new window

ok now it works.
But now all users are at home.
So it shows 0.
during the day I had a lot of locks.
What can I do against these locks ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the queries are very long, which ones you need ?
Here I have one long query.
What are the best MAXDOP settings and threshould settings ?

User generated image
MAXDOP = half cores ?
Threshould = 50 ? -> But what is 50 ?
No one can't says a good value for a MAXDOP for a query only by looking to the code.
You need to provide the query plan and the server configuration (it's a VM or physical machine? Has hyperthreading on? How many CPU? How many cores?).

By the way, why do you think that query is the one that has bad performance?
This query was found with the performance dashboard.
The SQL Server is physical.
It has 2 CPUs and 8 Cores.

By the way there is an article from Microsoft about this MAXDOP.
They speak about processors less than 8 then put it in.
But do they really mean processors or cores ?
They mean cores. But if your server has hyper threading then you need to count only half of the cores and if it's NUMA architecture then you should only count the cores for one CPU.
What you can do with that query in particular is to set MAXDOP=1 so the engine won't parallelize it.
when I have 8 cores, why not to set to 4 ?
And can you explain the threshold value of costs ? What is 50 ?
when I have 8 cores, why not to set to 4 ?
If it's a Quadcore NUMA architecture, then it's recommend to set the value to 4. If not, 8 it's the recommend value but since it's only a recommendation, you need to make tests to see if with 4 the performance is better.

And can you explain the threshold value of costs ? What is 50 ?
Sorry, now you lost me. What you mean with this?
How can I check if its NUMA on my server ?
Sorry, now you lost me. What you mean with this?

Here I mean the costs of parallelism. This is also set to 5.
But can you explain this a little bit ? What is 5 ?
What the SQL is doing when a query comes and the costs are set to 5 ?
Means that it will parallelize the query to run in 5 cores at same time. If the server has 8 cores, five of them will be used to run the query and the others three cores will be available for other tasks.
Is it not MAXDOP what you mean ?

Someone told me to put the costs to 50.
Sorry, now I saw your question about the threshold. Where are you using it?
The standard settings on my sql cluster are :

MAXDOP -> 0
Costs -> 5

But I get  a lot of parallelism waits.
I have to change this.

My hardware is :
2 processors of INTEL XEON 5460 at 3.16 GHz

In total I see 8 CPUs in the task Manager.
Try to change MAXDOP to 4. If you still having locks then reduce it to 1.

Can't see what's COSTS->5
Ok, when I understand the right way, I can choose MAXDOPS until 8.
But 1 is not logic, because this means just one CPU and then parallelism is off.
With MAXDOP=0 means they use default all processors and cores.
The costs are the field over the MAXDOP field : cost threshold for parallelism
This is set to 5 by default. This means 5 seconds.
Do I have to reboot, when I change MAXDOP or THRESHOULD ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But I have to do something.
Always I have PARALLELISM WAITS, sometimes over 20 waits.
Did you try to run the query without the MAXDOP option?
I cannot change anything in the query, because it comes from the application.
So MAXDOP is still default on my end = 0.
But I changed the THRESHOULD from 5 to 50.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What I want is -> no waits.

When the threshould was on 5 I had a lot of waits.
Now I have no waits anymore.
When the threshould was on 5 I had a lot of waits.
 Now I have no waits anymore.
Means that the engine isn't parallelize the query so it's the same as MAXDOP=1