Performance issues in NAV2017 CU11

ACaignieACaignie Member Posts: 91
Hello,

We recently migrated from NAV2009R2 to NAV2017CU11, and we have some long running SQL queries. Almost all of these queries have the same 'signature' in SQL, and start with 'SELECT TOP 50 ISNULL( ...), like this example from the vendor:

SELECT TOP (50) ISNULL("Vendor"."timestamp",@0) AS "timestamp",ISNULL("Vendor"."No_",@1) AS "No_",ISNULL("Vendor"."Name",@2) AS "Name",ISNULL("Vendor"."Search Name",@1) AS "Search Name", ... WHERE (ISNULL("Vendor"."Search Name",@1)=@11 AND ISNULL("Vendor"."No_",@1)<@12 OR ISNULL("Vendor"."Search Name",@1)<@11) ORDER BY "Search Name" DESC,"No_" DESC OPTION(OPTIMIZE FOR UNKNOWN, FAST 50)

Some of these long running queries (on other tables than vendor) take more than 50 seconds to run :o , on a table that only contains about 2.000.000 records.
After investigation it seems that these queries come from pages that are in the background, and have filters on them. If these pages are in the foreground then there is no performance issue, ony if they are minimized and another process is done by the user.

Is there any way to control this kind of behaviour? The 'RefreshOnActivate' property doesn't make any difference. I already disabled the sorting on the page to avoid sorting on flowfields, but this doesn't help.

Any ideas please?

Kind regards,
Andy

Best Answer

Answers

  • guidorobbenguidorobben Member Posts: 157
    indexes might help. But not always. For some reason, flowfields can be slow. When that happens, I rebuild them to queries.
  • ACaignieACaignie Member Posts: 91
    I have already investigated this, and there is only one flowfield in the query. This flowfield goes to the related table with the primary key (a simple LOOKUP flowfield). So I hope this is not the issue :-(
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    edited 2017-12-19
    This particular query picks up the TOP 50 records orderd by "Search Name". If you don't have an index on the table on that particular column the SQL Server must sort all the records in the table (2m in this case) by the "Search Name" column and return just the top 50.

    If you don't have an index starting from "Search Name" column don't be surprised the query takes long time.

    If you do have an index starting from the "Search Name" field it still might take a long time as the index migh got heavilly fragmented during the upgrade. This is happening because in NAV 2013 upwards the text fields are stored internally as nvarchar type, which takes 2 times more the space as varchar used in pre 2013 versions, and during conversion NAV rewrites all the tables, ruining the indexes.

    The wise thing would be to run some index optimisation routine to bring the internal indexes structure to some order.




    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • ACaignieACaignie Member Posts: 91
    Hi Slawek,
    Thanks for the answer. An index optimisation is done every night, and was also done after the upgrade.
    The issue is not the sorting I think. The recordset on the page is filtered, and these filters return a set of records that is only a fraction of the 2m records. If the user puts additional filters the page remains fast. However if he opens another page and does a modification to the same table, then it takes very long to refresh the page that is in the background.
    So I would like to know if this background refreshing can be disabled.

    Andy
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    I don't think that there are any methods or properties which would let you disable the background refresh. At least I am not aware of any.

    By the way - is your lookup field the "Search Name" field in the Vendor table, and are you filtering on that flowfield?
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • JuhlJuhl Member Posts: 724
    Hi Andy
    I came across something similar, maybe you can use this. But it seems MS does some crazy calculations in pages something.

    https://juhl.blog/2017/09/22/slow-customer-card-in-nav-2017/
    Follow me on my blog juhl.blog
  • ACaignieACaignie Member Posts: 91
    Hi Slawek,
    I'm sorry for the confusion but the query in my question was just an example of a 'SELECT TOP (50) ISNULL' query that takes a very long time, the actual query is on a customized table (without filters or sorting on flowfields). The user works on a small subset of that table (about 10.000 records out of 2M), the 1.900.000 other are filtered out by a key. I think that the background refresh does a table scan instead of using one the correct key. I now asked the user to close the page instead of minimizing it
  • ACaignieACaignie Member Posts: 91
    Hi Juhl,
    I have already removed AgedAccReceivableChart and AgedAccReceivableChart2, and commented out the calculation of BalanceExhausted and DaysPastDueDate. We have customers who has over 10.000 invoices, and it took NAV more than 2 minutes to open the page :o
    I asume everything works fine on their Cronus database, but on larger database ...
  • ACaignieACaignie Member Posts: 91
    Hi Slawek,
    Indexhinting is a good idea, however this was kind of the last option I wanted to explore.
    Thx for the answer
    Andy
Sign In or Register to comment.