mibuso.com

Microsoft Business Solutions online community
It is currently Sun May 19, 2013 2:49 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Flowfield slow for count type on NAV5SP1 SQL Server 2008
PostPosted: Mon Apr 19, 2010 2:00 am 
Offline

Joined: Fri Aug 06, 2004 9:30 pm
Posts: 899
Location: Richardson
Country: United States (us)
I have a customer database running under NAV 5 SP1 and SQL Server 2008.
When I ran a table to analyze data, it was extremely slow to come up - about 15 minutes, then a 10 second wait to move to a new line.
The table has a number of flowfields including several that use flowfilters.
By process of elimination using a list form, I determined the slowness is caused by one field that uses count. 4 other fields with the same set of filters on the target table that use sum instead work extrememly quickly.
Is there a reason why count would be extremely slow when sum is very fast?
This is an ISV supplied table, so I have to be careful about changes to their fields and keys.

They are using 3 filters in the table filter. I tried providing another key with the matched fields first, but that did not fix the problem.
If I just run a SQL query against the corresponding vsift view, it is fast.

_________________
David Machanick
http://mibuso.com/blogs/davidmachanick/


Top
 Profile  
 
 Post subject: Re: Flowfield slow for count type on NAV5SP1 SQL Server 2008
PostPosted: Mon Apr 19, 2010 6:25 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Thu Oct 16, 2003 8:50 am
Posts: 12265
Location: Brno
Country: Czech Republic (cz)
Sum could use SIFT technology, but Count needs to count the records... ;-)

_________________
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.


Top
 Profile E-mail WWW  
 
 Post subject: Re: Flowfield slow for count type on NAV5SP1 SQL Server 2008
PostPosted: Mon Apr 19, 2010 7:24 am 
Offline

Joined: Mon Mar 08, 2004 2:42 pm
Posts: 3255
Location: Hannover
Country: Germany (de)
How looks your flowField formula and exist there a optimal key in the table from where u calculate :?:
for example if u calculate in an Entry Table like ILE the count for an Item, and the calcformula is
Count("Item Ledger Entry" WHERE (Item No.=FIELD(Item No.))) u need in the table Item Ledger Entry a key that begins with the "Item No."
These key should not have many other fields in his structure.

so an example.

I will calulate the count of all ILE for an item. There exist some key's in the item ledger Entry table for that example.
The calcformula is: Count("Item Ledger Entry" WHERE (Item No.=FIELD(Item No.)))
So, when u run and profile the query on sql profiler, u can see following.
Index Seek with Index$xyz (xyz is the key no) with a read of < 20 so, ita good

Now, i will count the ILE with the "Item No." that is = the "External Document no." . I know it maks no sence, but it is for the example. So the calcformula is:
Count("Item Ledger Entry" WHERE (External Document No.=FIELD(Item No.)))

What we now can see on the profiler is, that the SQL Server must scan the Clusterd index :-( , because there is no key with the Externaö Document No. at the begin.
For count, NAV needs no key, but, if there a lot of datas in the table to calculate, a key should be created if the Flowfield is often used.

Regards

_________________
Do you make it right, it works too!


Top
 Profile  
 
 Post subject: Re: Flowfield slow for count type on NAV5SP1 SQL Server 2008
PostPosted: Mon Apr 19, 2010 7:28 pm 
Offline

Joined: Fri Aug 06, 2004 9:30 pm
Posts: 899
Location: Richardson
Country: United States (us)
Thanks.
Both replies are very helpful.
I already tried changing the flowfield to use a key with a different field order - the original field order started with a flowfilter - the new one starts with a field. If it is counting each row, then even using a key there is probably up to 10,000 rows to count for each value.
I will try running it thru the sql profiler.
If the add-on needs this field, the only solution for my data analysis may be to look at the data with a list form that excludes the flowfield with the count type, and then make changes to any user forms/reports that run slowly.

_________________
David Machanick
http://mibuso.com/blogs/davidmachanick/


Top
 Profile  
 
 Post subject: Re: Flowfield slow for count type on NAV5SP1 SQL Server 2008
PostPosted: Fri May 14, 2010 11:37 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Thu Jul 31, 2003 12:00 pm
Posts: 639
Location: Nürnberg
Country: Germany (de)
Hi,

well, to process a COUNT query the SQL Server also actually needs sufficient indexes to perform OK. While indexing of other SELECT queries could be a pain due to the "Dynamic Cursor" issues, these COUNTs (as SUM etc.) are not bothered by this!
Hence, if you detect a "bad" COUNT query (or SUM) you could try to apply an optimized index without necessarily changing the C/AL code ...

If you would like to post the affected query (Profiler recording) here, then maybe we could come up with some index proposal.

_________________
Jörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool


Top
 Profile E-mail WWW  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: