Hi guys,
i have turn SQL Server Profiler to view a why Planning Worsheet was taking about 2 minutes to make calculations to a single item, on a CRONUS database.
I had detect some lines with this parameters
SQL Profiler
CPU - 187
Reads - 66820
Duration - 186
The SQL Statement
DELETE FROM "Demo Database NAV (6-0)"."dbo"."CRONUS$Prod_ Order Capacity Need" WHERE (("Worksheet Template Name"=@P1)) AND (("Worksheet Batch Name"=@P2)) AND (("Worksheet Line No_"=@P3))
I turn the Client Monitor and see that C/AL CODE
ProdOrderCapNeed.DELETEALL;
TransferRouting;
I changed like the Styrk´s sugestion
http://dynamicsuser.net/blogs/stryk/archive/2010/10/22/solving-blocking-issues-practical-examples.aspxIF NOT ProdOrderCapNeed.ISEMPTY THEN
ProdOrderCapNeed.DELETEALL(TRUE);
ProdOrderCapNeed.DELETEALL;
TransferRouting;
but without luck.
I need some help to optimize this.
Can you help me?
Comments
2) Did those SQL statements effectivily delete some records?
BTW: if you only have some of them, it doesn't look as a problem. After all, they are all less then half a second.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
thanks for your answers.
I create a key with the
Worksheet Template Name,Worksheet Batch Name,Worksheet Line No.
like i saw on the codeunit code
2. I guess SQL is not deleting them.
So i have to conclude that running a planning worsheet for a single item is taking 2 minutes. For thousands of item´s it´s gonna be a huge time consuming task.
thanks for your answers.
1. I create a key with the
Worksheet Template Name,Worksheet Batch Name,Worksheet Line No. flelds
like i saw on the codeunit code
2. I guess SQL is not deleting them.
So i have to conclude that running a planning worsheet for a single item is taking 2 minutes. For thousands of item´s it´s gonna be a huge time consuming task.
thanks for your answers.
I create a key with the
Worksheet Template Name,Worksheet Batch Name,Worksheet Line No.
like i saw on the codeunit code
2. I guess SQL is not deleting them.
So i have to conclude that running a planning worsheet for a single item is taking 2 minutes. For thousands of item´s it´s gonna be a huge time consuming task.
RIS Plus, LLC
the error was mine.
When i put the code i forgot to take out the comments
The question is that
Planning Worksheet has taking about 15x more time to make calculations when the (field) Send Ahead Quantity is greater than zero in Item Routing Operations. How can i diagnose the problem?
If you want to cheCK IN SQL, I use SQL Profiler to trace what NAV is doing.
And if I want to make some totals of what's happening, I throw the result in Qure Workload Analyzer.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Great tool.
On attach i send this picture.
I follow the Styrk´s book and i see this parameters:
High Number of Reads >=1000
High Number of Writes>=50
Duration >=50
On this file i exceed this numbers. So what´s the next step? Reproduce the Query´s on Management Studio?
( it´s my 1st time doing this :oops: )
The line you showed has hight read and write but it is very low on duration, so at first sight it is not a problem.
And the sp_execute is difficult to find out what it does because it doesn't have the SQL statement.
You need to create 2 traces : 1 with "send Ahead Quantity" <> 0 and one with "send Ahead Quantity" = 0. Then analyse them with Qure Workload Analyzer to see where the differences are. Then we have an idea where to start looking.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
The idea is to check If there are any records within the filter before firing the DELETEALL to avoid blocking conflicts. This has minor impact on speed ...
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
we are trying to calculate the Planning Worksheet.
We notice when the "Send Ahead Quantity" is greater than zero then the calculate takes a long time.
I run with SQL Server Profiler and detect that
DELETE FROM "Demo Database NAV (6-0)"."dbo"."CRONUS$Prod_ Order Capacity Need" WHERE (("Worksheet Template Name"=@P1)) AND (("Worksheet Batch Name"=@P2)) AND (("Worksheet Line No_"=@P3)) as a duration bigger than the other statements.
I run the client Monitor and see the statement DELETEALL on CodeUnit 99000809.
Microsoft Reccomends ( re-index the database):
and then update the Statistics
Ok, but that would mean that the DELETEALL takes longer because there are more lines to delete (thus created before) if "Send Ahead Quantity" is greater than 0. This would be a logical problem.
Technically, there's no relation - the filter of the DELETEALL statement does not refer to "Send Ahead Quantity".
So could you determine how many lines are deleted then? Maybe it's plausible to have such a number of "Reads" and "Duration" ...
Have in mind that a DELETE also implicitly modifies all kinds of related statistics and indexes, but also the VSIFT (if existing).
Sufficient DB Maintenance like Index Defragmentation and Statistic Updates should be obligatory anyway, but I'm not sure if that will solve the problem ...
Actually I doubt that this DELETE is the core of the problem: you say the whole process takes about 2 minutes, the DELETE only takes 186 milliseconds ... (actually Kriki already highlighted that) ...
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
i had run again the SQL Profiler and open the Qure Workload Analyzer and sort by duration.
The Query that takes a long time is consuming 3 seconds. ( Prod_ Order Capacity Need).
This is critical?
Now the profile does not indicate the DELETE :oops:
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
i run the calculation for all items on the range and are queries that takes almost 2 minutes to complete, with a great number of read and writes.
Query that takes 2 minutes:
SELECT * FROM "Demo Database NAV (6-0)"."dbo"."CRONUS$Prod_ Order Capacity Need" WITH (UPDLOCK) WHERE (("Worksheet Template Name"=@P1)) AND (("Worksheet Batch Name"=@P2)) AND (("Worksheet Line No_"=@P3)) AND (("Operation No_"=@P4)) AND "Worksheet Template Name"=@P5 AND "Worksheet Batch Name"=@P6 AND "Worksheet Line No_"=@P7 AND "Operation No_"=@P8 AND "Status"=@P9 AND "Prod_ Order No_"<@P10 ORDER BY "Worksheet Template Name" DESC,"Worksheet Batch Name" DESC,"Worksheet Line No_" DESC,"Operation No_" DESC,"Status" DESC,"Prod_ Order No_" DESC,"Requested Only" DESC,"Routing No_" DESC,"Routing Reference No_" DESC,"Line No_" DESC
Is this significative?
Worksheet Template Name,Worksheet Batch Name,Worksheet Line No.,Operation No.
The query has consecutive parameters for each field, then repeats them. Any idea why?
Have you tried running the query manually outside of Navision?
http://mibuso.com/blogs/davidmachanick/