unexplainable perfomance

  • We are currently experiencing  some strange phenomenons, and I am hoping that someone may be able to shed some light on this.
    System: 4CPU x10 processors, 512GB memory, NetApp IO subsystem
        SQL2012 SP3 CU7 Std Ed. - 16 core, 128GB
        
    SQL instance used in ETL process.

    Change: Add luns to DB Server
        Move larger tables to filegroups on new luns.
        Shrink DB to leave 20% free in DB files.
        
    Post change observations (the problem)
        A SSIS Package went from running in 2 minutes to 10 minutes.
        The major step is a SQL query (90% of package duration) involving two tables - these were NOT moved in the change above.
            
        Query;
            insert into x1
            Select from tabB
                where col1 not in (select col1 from tabA)
        Table info:
            tabA - 500k+ rows, clustered +3 NC indices.
            tabB - 300k+ rows heap - no NC indices.
        
        Execution Plan:
            scan tabB
            index seek on tabA.ind2
            index scan on tabA.clustered
            index scan on tabA.ind4
        
        we investigated the tables rebuild / reorganized indices and updated stats. - this caused the query duration to prolong to between 13-17 minutes
        investigating the heap, i found 100k forwarded_row_count and rebuilt the heap. - query ran in 20 minutes.
        
    Can anyone shed some light onto what may be happening here? - I am trying to understand why "std maintenance" tasks designed to improve performance is resulting in exactly the opposite
    Thanks

    Edit:  from other internet hits on topic mentioning statistics sampling, I checked sampled rows.  This turned out to be <10% of the rows in the indices.  investigating further....

  • AnzioBake - Wednesday, April 26, 2017 1:32 AM

    We are currently experiencing  some strange phenomenons, and I am hoping that someone may be able to shed some light on this.
    System: 4CPU x10 processors, 512GB memory, NetApp IO subsystem
        SQL2012 SP3 CU7 Std Ed. - 16 core, 128GB
        
    SQL instance used in ETL process.

    Change: Add luns to DB Server
        Move larger tables to filegroups on new luns.
        Shrink DB to leave 20% free in DB files.
        
    Post change observations (the problem)
        A SSIS Package went from running in 2 minutes to 10 minutes.
        The major step is a SQL query (90% of package duration) involving two tables - these were NOT moved in the change above.
            
        Query;
            insert into x1
            Select from tabB
                where col1 not in (select col1 from tabA)
        Table info:
            tabA - 500k+ rows, clustered +3 NC indices.
            tabB - 300k+ rows heap - no NC indices.
        
        Execution Plan:
            scan tabB
            index seek on tabA.ind2
            index scan on tabA.clustered
            index scan on tabA.ind4
        
        we investigated the tables rebuild / reorganized indices and updated stats. - this caused the query duration to prolong to between 13-17 minutes
        investigating the heap, i found 100k forwarded_row_count and rebuilt the heap. - query ran in 20 minutes.
        
    Can anyone shed some light onto what may be happening here? - I am trying to understand why "std maintenance" tasks designed to improve performance is resulting in exactly the opposite
    Thanks

    Edit:  from other internet hits on topic mentioning statistics sampling, I checked sampled rows.  This turned out to be <10% of the rows in the indices.  investigating further....

    Can you post an execution plan for that query? It seems odd that there are three operators for Table A.
    Preferably an actual plan, but an estimated plan would be useful too.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • ChrisM@Work - Wednesday, April 26, 2017 5:06 AM

    Can you post an execution plan for that query? It seems odd that there are three operators for Table A.
    Preferably an actual plan, but an estimated plan would be useful too.

    Actual Query Plan attached

  • We have confirmed that updating statistics with fullscan did not improve query performance

  • GG-173138 - Wednesday, April 26, 2017 5:48 AM

    ChrisM@Work - Wednesday, April 26, 2017 5:06 AM

    Can you post an execution plan for that query? It seems odd that there are three operators for Table A.
    Preferably an actual plan, but an estimated plan would be useful too.

    Actual Query Plan attached

    Excellent, thanks. That's awesome...
    In the meantime, here's a logical equivalent which I'd expect to be faster - it's certainly cleaner:
    SELECT ...
    FROM dbo.TfmInvestorAccountTmp t
    WHERE NOT EXISTS (SELECT 1 FROM dbo.TfmInvestor i WHERE i.investorCIFNumber = t.investorCIFNumber)

    EDIT: Here's why...
    https://sqlperformance.com/2012/12/t-sql-queries/left-anti-semi-join

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • thanks, but we already have a solution.  we are just interested in an actual explainantion for future reference i.e why index maintenance resulted in this sudden change in behaviour

  • AnzioBake - Wednesday, April 26, 2017 1:32 AM

    Change: Add luns to DB Server
        Move larger tables to filegroups on new luns.
        Shrink DB to leave 20% free in DB files.
        
    Post change observations (the problem)
        A SSIS Package went from running in 2 minutes to 10 minutes.
        The major step is a SQL query (90% of package duration) involving two tables - these were NOT moved in the change above.

    Offhand I'm thinking the Shrink DB is a more likely culprit than index maintenance for the sudden change in behavior, especially since the 2 tables were not moved to the new file group, so they would have been most affected by the shrink when you tried to reclaim free space.

  • We came to the similar conclusion, i.e. the shrink affected the table.  That is when we started looking at the table and index (statistics) statuses. Rebuild indices and the table heap just worsened performance.  That is what we are struggling to understand - it did not just make it slightly worse, it doubled the execution time.  I neglected to mention that the data volumes also did not increase significantly in either table.

  • it's understandable, to shrink a database file, SQL Server will need to rearrange all the pages that are at or near the end of the file into other space that was already free or freed when you moved the other tables to the new filegroup.  When it does this, it doesn't really know the best way to rearrange those pages, it's just trying to do so as quickly as possible.  Paul Randal can explain it better than I ever could though:
    https://www.sqlskills.com/blogs/paul/why-you-should-not-shrink-your-data-files/

    As for your first index and stats maintenance, depending on how badly fragmented your index and heap were, and the fact that starting with SQL Server 2012 it doesn't do a full statistics recalculate with the index build anymore, the statistics could have gotten skewed depending on the sample:
    https://docs.microsoft.com/en-us/sql/relational-databases/indexes/reorganize-and-rebuild-indexes

  • Thanks Chris for the response.  
    As we  moved 400GB of data from the source files, and it is very unlikely to be require in the near future, the shrink was required.  
    Subsequent to the index rebuild and test we checked the stats and ran a stats update with fullscan and still did not see any performance improvement.

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply