Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Server Puzzling Performance


SQL Server Puzzling Performance

Author
Message
Francis Kioko
Francis Kioko
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 59
Hi Guys,

Been hanging around these forms for a very long time but never posted much. I am experiencing something that is very puzzling, I have a SQL Server 2012 running on Windows 2012 Standard 64bit in a virtualized environment. The Physical server has 24GB Ram and I have allocated 8 GB Ram to this VM. The other VMs on this server take up another 8GB of RAM.
The puzzling thing is that there is a query that I run on this server and it take more than 4 mins to execute if the Max Memory setting of the SQL Server is set at any value over 3856 MB.
When i set the Max memory setting to anything below this value the query executes in less than 2 secs. Have any of you ever expeirenced anything like this before and if so what is the cause of it and how can I fix it to enable me allocate more RAM to the server.
I forgot to mention that this server is not running any other services.

FK
P.S. I can post the query if it is necessary.
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 4076
Francis Kioko (10/24/2013)
When i set the Max memory setting to anything below this value the query executes in less than 2 secs.
i dont think reducing memory can boost the performance.

the execution time in 4 min (with more mem) and 2 secs (with less memory) is it a regular pattern ? i doubt here though

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Francis Kioko
Francis Kioko
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 59
Hi

It sounds crazy but it is very true. I have tried it in two separate environments i.e. another physical host using SQL Server 2012 and SQL Server 2008 and I get the same results. Below a certain MAX Memory threshold which varies from 4323 to 3856 the performance of the query increases exponentially from minutes (4 to 10 mins) to less than 4 secs. The query in question is below

SELECT t11.DocNum, convert(nvarchar, t11.DocDate,103), t11.Filler as 'Origin W/H', 
t11.U_RecWshe as 'Final W/H', t12.ItemCode, t12.Dscription,
(SELECT t13.ItmsGrpNam FROM OITB t13 , OITM t14 WHERE t13.ItmsGrpCod=t14.ItmsGrpCod and t14.ItemCode=t12.ItemCode) as 'Item Group', t12.Quantity
FROM OWTR t11, WTR1 t12
WHERE t11.DocEntry=t12.DocEntry and t11.DocNum in
(SELECT t0.DocNum FROM OWTR t0 t0.U_TrnType=1 AND t0.DocDate<='2012/12/31' and t0.U_EType=0
AND CONVERT(NVARCHAR, t0.DocNum) NOT IN
(SELECT CONVERT(NVARCHAR,ISNULL(t11.U_TrnDocNo,'')) FROM OWTR t11))



Has anyone ever encountered this?

Basically when it takes 4 mins during that time the CPU usage shoots up to 100% for the entire time.

Regards
FK
P.S. I have attached actual query execution plans.
Attachments
4mins.sqlplan (11 views, 152.00 KB)
2sec.sqlplan (9 views, 171.00 KB)
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 4076
Francis Kioko (10/24/2013)
It sounds crazy but it is very true. I have tried it in two separate environments i.e. another physical host using SQL Server 2012 and SQL Server 2008 and I get the same results. Below a certain MAX Memory threshold which varies from 4323 to 3856 the performance of the query increases exponentially from minutes (4 to 10 mins) to less than 4 secs.

can you also provide result of set stattics io on and set statistics cpu on from both environments(dont forget to remove exec plan selection )

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Francis Kioko
Francis Kioko
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 59
can you also provide result of set stattics io on and set statistics cpu on from both environments(dont forget to remove exec plan selection )


Here are the results
When the memory is reduced to below the threshold and the query executes in less than 2 seconds
SQL Server parse and compile time:
CPU time = 327 ms, elapsed time = 328 ms.

SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.

(45 row(s) affected)
Table 'OWTR'. Scan count 48, logical reads 54504, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 83, logical reads 298, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'WTR1'. Scan count 38, logical reads 187, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'OITB'. Scan count 0, logical reads 72, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'OITM'. Scan count 0, logical reads 108, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

SQL Server Execution Times:
CPU time = 594 ms, elapsed time = 415 ms.


When i increase the max memory and the query runs for more than 4 mins these are the results

SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.

(45 row(s) affected)
Table 'OWTR'. Scan count 47, logical reads 233120944, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'WTR1'. Scan count 38, logical reads 187, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 84, logical reads 300, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'OITB'. Scan count 0, logical reads 72, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'OITM'. Scan count 0, logical reads 108, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

SQL Server Execution Times:
CPU time = 1138776 ms, elapsed time = 292035 ms.

The difference with in both results is that when the first query was run the max memory setting was set at 3856 and it took a couple of seconds to execute.
When i increased the memory to 3857 the exact same query took almost 5 mins to execute.

Regards
FK
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 4076
SscLover (10/25/2013)
Since no one has replied on the topic, thats new thing to me that increasing the server memory causing bad plan for query,
yes server memory is one of aspect which affect the execution plan
but it should not go worse after increasing the memory,

i request you please update the statistics with full table scan for all underlying tables affecting the query.
All the perfect size bullets to hit the bird BUT here scenario is bit different . OP is using same server the only change which is occurring is "increasiing the memory" but server is SAME(or did i overlook some here?)?

What strange thing here is performance is getign worst after addition of memory ?

See the CPU and logical reads of first table from the last post of OP.

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Francis Kioko
Francis Kioko
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 59
Hi SSClover

Your redesigned query is very good but unfortuantly it still runs slower. From what i can tell, it seems to be a problem with SQL Server Database Engine and not the query itself. Has anyone ever experienced this?

Regards
FK
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 4076
Francis,

Can ypu try one more thing ?

start the profiler and look for "Sort Warning" option and see if its is coming when you execute the SP ? loo in both the cases .

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search