Slow Only on role center

Belias
Member Posts: 2,998
Hi everyone,
I've a pretty strange behavior here: i've tried to profile it and i identified a single, long running query, but i can't figure out what can have generated it.
Specs:
nav2009r2 build 32775
sql 2008r2
But first, a litlle explanation:
I have a list of serial numbers, and a factobox that shows every item ledger entry related to that serial no.
properties of the factbox part in my page:
if i run the page through obj designer (as explained, it's a list with a factbox list) everything works fine, but if i access the list through the rolecenter menu, the following query is fired. This query takes 30 seconds to execute, because it reads 310133 records.
:-k I am figuring out something while i'm writing, just tell me if i'm talking s**t
"Serial No.,Posting date" key is not maintained on the item ledger entry (maintainsqlindex = false), but i have "Serial No.,Responsibility Center Code,Source No.,Location Code" key that is actually maintained. Actually, ordering by this latter key make the page works smoothly, but why sql can't see this key if i'm running the page through role center?!?!
Thanks in advance for your inputs! I hope I explained it clearly!
I've a pretty strange behavior here: i've tried to profile it and i identified a single, long running query, but i can't figure out what can have generated it.
Specs:
nav2009r2 build 32775
sql 2008r2
But first, a litlle explanation:
I have a list of serial numbers, and a factobox that shows every item ledger entry related to that serial no.
properties of the factbox part in my page:
subformview SORTING(Serial No.,Posting Date)
subformlink Serial No.=FIELD(Code)
if i run the page through obj designer (as explained, it's a list with a factbox list) everything works fine, but if i access the list through the rolecenter menu, the following query is fired. This query takes 30 seconds to execute, because it reads 310133 records.
SELECT TOP 1 * FROM mydb$Item Ledger Entry" WITH (READUNCOMMITTED) ORDER BY "Serial No_","Posting Date","Entry No_" OPTION (OPTIMIZE FOR UNKNOWN)
:-k I am figuring out something while i'm writing, just tell me if i'm talking s**t

"Serial No.,Posting date" key is not maintained on the item ledger entry (maintainsqlindex = false), but i have "Serial No.,Responsibility Center Code,Source No.,Location Code" key that is actually maintained. Actually, ordering by this latter key make the page works smoothly, but why sql can't see this key if i'm running the page through role center?!?!
Thanks in advance for your inputs! I hope I explained it clearly!
0
Answers
-
It is interesting that there is no filter... than it reads all entries, sort them, and than it take the first one... and it seems that SQL select clustered index to read all th records, because it is much "cheaper" to read them and sort them (which needs because there is no index with same order which will solve it). OPTIMIZE FOR UNKNOWN - I think that it s used only when the page is reading the records. It means first time the page is displayed, it is trying to read the first record from all item ledger entries and display it. Try to set some default filter which will be than overwritten with the relation filter... but it is just tip, never tried that...0
-
Yes, putting a
SETRANGE("entry no.",1,10000)
in the onopenpage of the factbox "solves" the problem, because sql fires the following querySELECT TOP 1 * FROM mydb."dbo"."mycompany$Item Ledger Entry" WITH (READUNCOMMITTED) WHERE (("Entry No_">=@P1 AND "Entry No_"<=@P2)) ORDER BY "Serial No_","Posting Date","Entry No_" OPTION (OPTIMIZE FOR UNKNOWN)
my conclusion is that nav tries to open the factbox like this:
1. does not apply the subformlink property
2. apply the Subformview property (but the key is not maintained and nav have to sort the entire table with an unexisting key)
----> fires a query. (long running)
3. apply the subformlink property.
----> fires a query. (fast even with an unmaintained key, because of a tiny recordset)
actually, the first query is useless, and is only fired when the main page is embedded in the role center...if you run the same page not "embedded", the process is:
1,2,3,query! That in my opinion is the correct procedure. This evening i'm installing the latest hotfix in our test environment and we'll see if it solves the problem. Otherwise, i'll report it to Microsoft.
Thanks for Now0 -
Than it looks like my initial guess hit the spot... :-) Good that it is working...0
-
kine wrote:Than it looks like my initial guess hit the spot... :-) Good that it is working...
i spent one hour trying to figure out where does that TOP 1 query was started (after giving it up :whistle: ,search the problem somewhere else and ask here)0 -
I think that the TOP 1 is specific for the FactBox, because RTC assumes that it is displaying one record only...0
-
-
posted on connect, "like it" if you want
https://connect.microsoft.com/dynamicssuggestions/feedback/details/689087/slow-factbox-on-rolecenter0 -
We have isolated the problem and replicated on a cronus. it will probably be escalated as a bug (I'm waiting for confirmation about this), and hopefully hotfixed
Thanks to Duilio Tacconi of the italian CSS team for his effort and competence! =D>
In the meantime, I found a workaround to avoid the issue: set the sorting key through SETCURRENTKEY in the onaftergetrecord trigger, and remove every single sorting property (sourcetableview in the factbox and subformview in the FB part of the main page). It's weird, but this is the only way to make it work fastIF NOT KeyIsSet THEN BEGIN SETCURRENTKEY("Serial No.","Posting Date"); KeyIsSet := TRUE; END;
PS: no, the onopenpage trigger does not work0 -
Finally you found it. Well done, Mirko! These are the things you spend hours and hours on and get frustrated, but in the end the whole NAV world could participate from your work."Money is likewise the greatest chance and the greatest scourge of mankind."0
-
einsTeIn.NET wrote:....but in the end the whole NAV world could participate from your work.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions