List form selecting every field causing slow performance?

Alex_Chow
Member Posts: 5,063
We have a database that is on version 3.7B but the executables are upgraded to NAV2009 SP1.
Everywhere in the system, the performance has increased except for the item card and the item list. The performance on the item card and list has severly decreased in performance, it takes roughly 3-4 seconds when I click on each item from the list. When I push page up or page down, I have to wait about 3-4 seconds as well.
There are only 30,000 items in the system, however, there are 280 fields in the item table with quite a few flowfields.
Initially, I thought the flowfields displayed on the list is causing the problem. I created a list form with only the item number and description, but the performance is the same.
Turning on the client monitor, it seems that the SELECT query is causing the slowdown. It's select every field on the item table, then the following: WHERE "No_">@P1 ORDER BY "No_" OPTION (OPTIMIZE FOR UNKNOWN)
The WHERE "No_"=@P1 ORDER BY "No_" OPTION (OPTIMIZE FOR UNKNOWN) is causing some problems as well.
The customer list doesn't seem to have a problem with the query.
A couple of interesting points:
- The database uses $ as part of the item primary key
- Database is SQL Server 2008 Standard
Any help would be greatly appreciated!
Everywhere in the system, the performance has increased except for the item card and the item list. The performance on the item card and list has severly decreased in performance, it takes roughly 3-4 seconds when I click on each item from the list. When I push page up or page down, I have to wait about 3-4 seconds as well.
There are only 30,000 items in the system, however, there are 280 fields in the item table with quite a few flowfields.
Initially, I thought the flowfields displayed on the list is causing the problem. I created a list form with only the item number and description, but the performance is the same.
Turning on the client monitor, it seems that the SELECT query is causing the slowdown. It's select every field on the item table, then the following: WHERE "No_">@P1 ORDER BY "No_" OPTION (OPTIMIZE FOR UNKNOWN)
The WHERE "No_"=@P1 ORDER BY "No_" OPTION (OPTIMIZE FOR UNKNOWN) is causing some problems as well.
The customer list doesn't seem to have a problem with the query.
A couple of interesting points:
- The database uses $ as part of the item primary key
- Database is SQL Server 2008 Standard
Any help would be greatly appreciated!
Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
0
Comments
-
Ok, I know where the performance problem is.
The problem is caused by the number of Normal fields. I copied and pasted the SELECT statement into the SSMS and ran the query.
If I ran the query as is, it takes 7 seconds to execute. As I start to trim down the number of fields in the SELECT statement, the performance started to be faster and faster.
Anyone know why this is? Does it mean that if you have a lot of add-ons, your performance will always suck?
And why is it getting all the fields on the record when I open the item card? I recall in prior versions, it only grabbed the fields you have on the field?
And why is it grabbing all the records in the WHERE No_ > xxx? When I'm only getting a single item on the item card?Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
SELECT * is a huge killer in Navision. In SQL there is no way for Navision to tell SQL only to pull the needed fields.
I wrote a Blog about his some time ago http://dynamicsuser.net/blogs/singleton/archive/2009/03/14/select-from-and-how-to-do-it-better-in-nav.aspx
At Convergence a couple of years back, I found that someone in Denmark did read this. There are plans in place to put some sort of functionality like this in Navision, but at the moment the limitations are compatibility with the Native database, and how to cache selected queries. On tables with lots of fields though this will make a huge difference.David Singleton0 -
Alex Chow wrote:... I recall in prior versions, it only grabbed the fields you have on the field?
...
No it has always grabbed everything. One of the reasons Navision can't work over a wan.David Singleton0 -
It looks like they did change it a bit. Instead of SELECT *, the SELECT statement actually selects all the Normal fields.
So it's a giant SELECT query.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
David Singleton wrote:Alex Chow wrote:... I recall in prior versions, it only grabbed the fields you have on the field?
...
No it has always grabbed everything. One of the reasons Navision can't work over a wan.
Sorry, I was thinking flowfields.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
Indeed, the problem with SELECT * is that mostly way too many fields are retrieved, remarkably increasing the I/O.
In newer versions you see an explicit SELECT [timestamp], [No_],... only on tables which have a BLOB field defined (e.g. "Item"."Picture"). The idea is obviously NOT to query all fields if not really needed (see David's "SQLRecord" idea).
Currently, even the explicit SELECT queries the BLOBS ...
... and this is often the trouble with the queries you describe. I had similar cases, and here the solution was to disable the BLOB in NAV; e.g. creating dedicated tables as "Item Picture", moving the BLOB to it. In most cases the queries performed remarkably (!) better!
See also http://dynamicsuser.net/blogs/stryk/archive/2009/02/12/blob-fields-with-nav-amp-sql.aspx
Cheers,
JörgJörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
Thanks Jorg for the tip!
In the case where Picture is a standard table in the item table, do you recommend just disabling the field? OR deleting it completely?Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
Well, what we did was this:
1. Create new table "Item Picture" ("Item No." (PK), "Picture")
2. Move all "Pictures" from "Item" to "Item Picture" (using SQL as described in my BLOG, or via NAV CU)
3. Set "Enabled" to FALSE for "Picture" in table "Item"
In those Forms and Reports where "Picture" is used, we changed the code, pointing to the new table.
Hope this helps you a little.
Cheers,
JörgJörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
stryk wrote:3. Set "Enabled" to FALSE for "Picture" in table "Item"
Got it. I just want to make sure setting the enable property to No will cause the select to use the field.
The client does not store pictures on the blog field anyway, they use Record Links.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
Thanks Jorg, the Item List is BLAZING now!
Didn't know a simple BLOG field can cause so much harm.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
Cool! 8)
I guess it's the way how BLOBs are stored in the database - not part of the CI. I think that there is at least some pointer to "somewhere" where the BLOB "might" be - even if not used ... and just checking if there's a BLOB or not obviously causes lot of I/O ... :-kJörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
There were some values in the BLOG field. I had to clear it out manually.
It's uploaded by accident a long time ago.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
But be careful with disable BLOB-fields and using webservices : see my blog : http://mibuso.com/blogs/kriki/2010/02/17/am-i-a-detective/Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
be aware if you make only a techn. upgrade to 2009SP. Some C/AL commands are other interpreded then in the older versionsl.
We had the phenomenon with the "Analysis by Dimensions" and here, for example, with the Codeunit 7153 Funktion DimCodeToOption().
The problem was here, that in the older version the first parameter is code now its Text. Now, with tech. upgrade the CASE command checks if uppercase or lowercase (in older version that was not the case). So, u must check also your customized code, if there is some code like this.
regardsDo you make it right, it works too!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