Posting speedup when using Analysis Views

imhotephimhoteph Member Posts: 5
edited 2012-11-29 in SQL Performance
Hi all,

when using Analysis views and posting GL entries, which don't match dimension criteria, NAV 2009 in Codeunit 410 generate very huge SQL query which take tooooo long.

When you want speedup, update code in UpdateEntries procedure from
IF LedgEntryDimEntryNo < MaxNumber THEN
    GLEntry.SETRANGE("Entry No.",LedgEntryDimEntryNo,MaxNumber);
UNTIL (GLEntry.NEXT = 0) OR (LedgEntryDimEntryNo = 0);
IF ShowProgressWindow THEN
  UpdateWindowCounter(GLEntry."Entry No.");
to
BreakLoop is local boolean variable

  IF LedgEntryDimEntryNo < MaxNumber THEN
    GLEntry.SETRANGE("Entry No.",LedgEntryDimEntryNo,MaxNumber);
//UNTIL (GLEntry.NEXT = 0) OR (LedgEntryDimEntryNo = 0);
  BreakLoop := LedgEntryDimEntryNo = 0;
  IF NOT BreakLoop THEN
    BreakLoop := GLEntry.NEXT = 0;
UNTIL BreakLoop;
IF ShowProgressWindow THEN
  UpdateWindowCounter(GLEntry."Entry No.");

This is because NAV client evaluate both expressions in until clause and because LedgEntryDimEntryNo is zero, then GLEntry.NEXT generate SQL query with full scope of "Entry No." fields (0..MaxNumber)

Hope this anybody help.
Jan Esterka
NAV Freelancer
LUKROM Holding
Profile
Sign In or Register to comment.