Slow search

Working with NAV 2009.

I have a query on Item ledger entry which is slow.
It seems, that the first 2 iterations take a lot of time (about 1 minute), but after that it is fast (within the second).
The code I use:

ILE.RESET;
ILE.SETRANGE(ILE."Item No.", "Item No.");
ILE.SETRANGE(ILE.Open, TRUE);

ILE.SETCURRENTKEY("Item No.",Open,"Variant Code","Location Code","Item Tracking","Lot No.","Serial No.");

IF ILE.FINDSET
THEN REPEAT
<create temp table records>
UNTIL (ILE.NEXT = 0);

When I close the program and reopen it there is no delay. But when Navision is closed and reopened the same problems pops up.

Best Answers

Answers

  • Slawek_Guzek
    Slawek_Guzek Member Posts: 1,692
    How many entries do you have in your Item Ledger Entry?
    How many enties, on average, are you expecting to copy to temp table in your loop?
    Slawek Guzek - www.yitron.co.uk
    Business Central, MS SQL Server, Wherescape RED;
  • Adri
    Adri Member Posts: 8
    about 4.5 milion
  • Slawek_Guzek
    Slawek_Guzek Member Posts: 1,692
    Are you on SQL or Native?
    Slawek Guzek - www.yitron.co.uk
    Business Central, MS SQL Server, Wherescape RED;
  • Adri
    Adri Member Posts: 8
    SQL
  • Adri
    Adri Member Posts: 8
    Thank you for your help!