• paul.biltcliffe 32759 (12/5/2016)


    In regards nchar and nvarchar, its purely down to the 3rd party design for this.

    There's a lot of this throughout their table designs, however they have very little willingness to want to make their application better. Frustrating to say the least.

    I've even raised issues regarding bringing back TOP 99999 back to user front end. Makes zero sense to bring back so much data.

    On a further note of the problem query, I have today noticed that the query causing the problem seems to hang for what I believed to be a specific parameter 'A4'. What I've since found following further SQL traces is that at some point during the query being repeatedly processed, all parameter values passed into the stored procedure start to show larger reads against the table at some point. It just happens 'A4' value reads 67K rows. Most other parameter values return under 1K rows. Usually no 'heap' appears in the execution plan, however, it appears a 'heap' does start to appear around the build up of the problem.

    If the 'A4' value runs as expected it shows as follows in a SQL trace:

    query executed with A4 value, 780 CPU, 3780 Reads,1 Writes

    However, this morning I started to see the same query produce following output in a SQL trace file.....

    10:42

    A4 executed with, 84366 CPU, 4906036 Reads, 110014 Writes

    10:45

    A4 executed with, 80091 CPU, 5284791 Reads, 110007 Writes

    10:46

    A4 executed with, 97812 CPU, 6179117 Reads, 110012 Writes

    I'm running further analysis to see what happens in the database leading up to the problem.

    Every time statistics update on the 'agldimvalue' table is executed, it resolves the problem.

    regards

    Paul

    This is known as the data value skew problem. And when you have it (and most databases do to some degree - often severe) you simply MUST do some things differently or the standard and expected behaviors of the SQL Server optimizer and query execution engine will simply CRUSH your server. I have come across clients that literally couldn't buy big enough hardware, but a few fixes in the app and perhaps some indexing improvements and all of a sudden they didn't need bigger hardware.

    Feel free to give my contact information to the ISV and see if they will be willing to have a free chat with me. I have been consulting on just the SQL Server relational engine for 20 years. I also have multiple successes under my belt with software vendors and I can promise that yours won't be any different from them. EVERYONE does the same suboptimal stuff!! 😎

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service