Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Database suddenly slow

Database suddenly slow

Scheduled Pinned Locked Moved Database
databasecsharpcom
7 Posts 5 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Super Lloyd
    wrote on last edited by
    #1

    One of our reporting database is becoming mysteriously slow in the last 2 weeks. While it was working perfectly fine before that. There was 2 tables with about 10 millions records each and it was working fine. Now I have 3 tables with about 10 millions records (dunno if it change anything) bu t I am starting to have plenty of Timeout exception! :O Case in point This is simplest EF call:

    (
    from ite in this.ItemTransactions
    where ite.DataSourceId == 3
    orderby ite.ItemTransactionId descending
    select new { ite.PrimaryIdInDataSource }
    ).FirstOrDefault()

    and it generates this simple SQL

    -- Region Parameters
    DECLARE @p0 Int = 3
    -- EndRegion
    SELECT TOP (1) [t0].[PrimaryIdInDataSource]
    FROM [ItemTransaction] AS [t0]
    WHERE [t0].[DataSourceId] = @p0
    ORDER BY [t0].[ItemTransactionId] DESC

    Now it takes 2 minutes to run that SQL code in SQLSMS, which is suspiciously slow for only 6 millions records. Also, when I run my C# code, EF timeout! Even thought I set the command timeout to be 10 minutes! :O Most puzzling all this code was running fine 2 weeks ago... Can't find the reason in the TFS history.. :~ -- [EDIT: Found it] Between 2 recreations and data repopulation of the database.. someone one changed the primary key of many tables that were used in joins from CLUSTERED to NONClUSTERED index That seemed like a good idea at the times, they said.... ;P

    A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

    CHill60C Richard DeemingR U 3 Replies Last reply
    0
    • S Super Lloyd

      One of our reporting database is becoming mysteriously slow in the last 2 weeks. While it was working perfectly fine before that. There was 2 tables with about 10 millions records each and it was working fine. Now I have 3 tables with about 10 millions records (dunno if it change anything) bu t I am starting to have plenty of Timeout exception! :O Case in point This is simplest EF call:

      (
      from ite in this.ItemTransactions
      where ite.DataSourceId == 3
      orderby ite.ItemTransactionId descending
      select new { ite.PrimaryIdInDataSource }
      ).FirstOrDefault()

      and it generates this simple SQL

      -- Region Parameters
      DECLARE @p0 Int = 3
      -- EndRegion
      SELECT TOP (1) [t0].[PrimaryIdInDataSource]
      FROM [ItemTransaction] AS [t0]
      WHERE [t0].[DataSourceId] = @p0
      ORDER BY [t0].[ItemTransactionId] DESC

      Now it takes 2 minutes to run that SQL code in SQLSMS, which is suspiciously slow for only 6 millions records. Also, when I run my C# code, EF timeout! Even thought I set the command timeout to be 10 minutes! :O Most puzzling all this code was running fine 2 weeks ago... Can't find the reason in the TFS history.. :~ -- [EDIT: Found it] Between 2 recreations and data repopulation of the database.. someone one changed the primary key of many tables that were used in joins from CLUSTERED to NONClUSTERED index That seemed like a good idea at the times, they said.... ;P

      A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

      CHill60C Offline
      CHill60C Offline
      CHill60
      wrote on last edited by
      #2

      There are umpteen reasons why a database may start having performance issues - it is unlikely to be your unchanged code! This post lists some of the troubleshooting steps you can try to either find out what is wrong and/or just do some housekeeping that should help [SOLVED] SQL Server database slowness troubleshooting - Spiceworks[^]

      S 1 Reply Last reply
      0
      • S Super Lloyd

        One of our reporting database is becoming mysteriously slow in the last 2 weeks. While it was working perfectly fine before that. There was 2 tables with about 10 millions records each and it was working fine. Now I have 3 tables with about 10 millions records (dunno if it change anything) bu t I am starting to have plenty of Timeout exception! :O Case in point This is simplest EF call:

        (
        from ite in this.ItemTransactions
        where ite.DataSourceId == 3
        orderby ite.ItemTransactionId descending
        select new { ite.PrimaryIdInDataSource }
        ).FirstOrDefault()

        and it generates this simple SQL

        -- Region Parameters
        DECLARE @p0 Int = 3
        -- EndRegion
        SELECT TOP (1) [t0].[PrimaryIdInDataSource]
        FROM [ItemTransaction] AS [t0]
        WHERE [t0].[DataSourceId] = @p0
        ORDER BY [t0].[ItemTransactionId] DESC

        Now it takes 2 minutes to run that SQL code in SQLSMS, which is suspiciously slow for only 6 millions records. Also, when I run my C# code, EF timeout! Even thought I set the command timeout to be 10 minutes! :O Most puzzling all this code was running fine 2 weeks ago... Can't find the reason in the TFS history.. :~ -- [EDIT: Found it] Between 2 recreations and data repopulation of the database.. someone one changed the primary key of many tables that were used in joins from CLUSTERED to NONClUSTERED index That seemed like a good idea at the times, they said.... ;P

        A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        Check the execution plan. Check that you have the correct indexes on the tables. Try running Brent Ozar's First Responder Kit[^] on the server to see if there are any obvious errors. You mention that the size of the data has increased. Does it now exceed the server's available memory? If it keeps having to go back to disk to load the data, then that can dramatically slow things down. Especially if the data isn't on an SSD.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        S 1 Reply Last reply
        0
        • CHill60C CHill60

          There are umpteen reasons why a database may start having performance issues - it is unlikely to be your unchanged code! This post lists some of the troubleshooting steps you can try to either find out what is wrong and/or just do some housekeeping that should help [SOLVED] SQL Server database slowness troubleshooting - Spiceworks[^]

          S Offline
          S Offline
          Super Lloyd
          wrote on last edited by
          #4

          Found it... Between 2 recreations and data repopulation.. someone one changed the primary key of many tables that were used in joins from CLUSTERED to NONClUSTERED index That seemed like a good idea at the times, they said.... ;P

          A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

          1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            Check the execution plan. Check that you have the correct indexes on the tables. Try running Brent Ozar's First Responder Kit[^] on the server to see if there are any obvious errors. You mention that the size of the data has increased. Does it now exceed the server's available memory? If it keeps having to go back to disk to load the data, then that can dramatically slow things down. Especially if the data isn't on an SSD.


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            S Offline
            S Offline
            Super Lloyd
            wrote on last edited by
            #5

            Found it... Between 2 recreations and data repopulation.. someone one changed the primary key of many tables that were used in joins from CLUSTERED to NONClUSTERED index That seemed like a good idea at the times, they said.... ;P

            A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

            M 1 Reply Last reply
            0
            • S Super Lloyd

              Found it... Between 2 recreations and data repopulation.. someone one changed the primary key of many tables that were used in joins from CLUSTERED to NONClUSTERED index That seemed like a good idea at the times, they said.... ;P

              A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              :laugh: :laugh: :laugh: would you like to borrow my clue bat.

              Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

              1 Reply Last reply
              0
              • S Super Lloyd

                One of our reporting database is becoming mysteriously slow in the last 2 weeks. While it was working perfectly fine before that. There was 2 tables with about 10 millions records each and it was working fine. Now I have 3 tables with about 10 millions records (dunno if it change anything) bu t I am starting to have plenty of Timeout exception! :O Case in point This is simplest EF call:

                (
                from ite in this.ItemTransactions
                where ite.DataSourceId == 3
                orderby ite.ItemTransactionId descending
                select new { ite.PrimaryIdInDataSource }
                ).FirstOrDefault()

                and it generates this simple SQL

                -- Region Parameters
                DECLARE @p0 Int = 3
                -- EndRegion
                SELECT TOP (1) [t0].[PrimaryIdInDataSource]
                FROM [ItemTransaction] AS [t0]
                WHERE [t0].[DataSourceId] = @p0
                ORDER BY [t0].[ItemTransactionId] DESC

                Now it takes 2 minutes to run that SQL code in SQLSMS, which is suspiciously slow for only 6 millions records. Also, when I run my C# code, EF timeout! Even thought I set the command timeout to be 10 minutes! :O Most puzzling all this code was running fine 2 weeks ago... Can't find the reason in the TFS history.. :~ -- [EDIT: Found it] Between 2 recreations and data repopulation of the database.. someone one changed the primary key of many tables that were used in joins from CLUSTERED to NONClUSTERED index That seemed like a good idea at the times, they said.... ;P

                A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                U Offline
                U Offline
                User 12370310
                wrote on last edited by
                #7

                Check your index if the fragmentation is high then re organize it or re index. And If you have index like non cluster or cluster and you changed it or add new index please review.thanks

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups