Db is slow

  • Hi SQL Gurus,

    One of our production database is running very slow. I checked blocking , I didn't see any blocking. Also, check for running processes and look for any waittype. I see null. How to get more insights on a running sql server for a specific databases?

    What all can he checked in this scenario?

    Also, How to check what are the most or top 3-5 databases which are currently active on the server? any query please share and on what columns do we need to aggregate to check to see the top 5 dbs active at this point of time and taking up resources.

    This is a shared SQL instance and many dbs are hosted on it. each of 3TB in size. We have like 15-20 dbs hosted on that instance. Its a testing server. it has 16cpus and 256 gb RAM. SQL Server 2017 Enterprise Edition.

    Kind Regards,

    Bob

     

  • There are any number of things to check, but I generally focus on wait statistics and query times. And honestly, mostly query times. Wait statistics tell you what things are slowing down on, but not why. Queries are all the what and the why. Assuming you don't have monitoring set up, you can use the DMVs like sys.dm_exec_query_stats to see which queries currently in cache are using the most resources, running the longest, or are called most frequently. That should let you know what's up. Go from there.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Before I had access to monitoring tools I found (and still do) 'sp_WhoIsActive' to be immensely helpful to gain insight as to what is happening right now.


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • Do you have 15-20 3TB databases on a test server and one of the databases is production?

    How much storage do you have? It sounds like you have 30-60 TB in databases. Is it possible you are running out of space? Are all the databases accessing the same volume(s)?

    We use EC2 instances in AWS and it is cheaper to create one large volume, but I think it leads to slow disk access, especially if tempdb is on the same volume.

  • Ed B wrote:

    Do you have 15-20 3TB databases on a test server and one of the databases is production?

    How much storage do you have? It sounds like you have 30-60 TB in databases. Is it possible you are running out of space? Are all the databases accessing the same volume(s)?

    We use EC2 instances in AWS and it is cheaper to create one large volume, but I think it leads to slow disk access, especially if tempdb is on the same volume.

    On Prod we have 1 copy of the database.

    All servers and storage is Microsoft Azure and Azure storage.

     

     

  • Grant Fritchey wrote:

    There are any number of things to check, but I generally focus on wait statistics and query times. And honestly, mostly query times. Wait statistics tell you what things are slowing down on, but not why. Queries are all the what and the why. Assuming you don't have monitoring set up, you can use the DMVs like sys.dm_exec_query_stats to see which queries currently in cache are using the most resources, running the longest, or are called most frequently. That should let you know what's up. Go from there.

    Thanks Grant for the direction path.

    One more thing, I would like to ask.

    End user or testing team says , they ran the workload for 10 users it returns in 60 secs but when they run same workload 100 users, the queries are dead slow.. taking more than 15mins – 30 mins.

    What needs to checked from SQL Server/db side and what information we need to get from the end user to get more clarity? do we need any kind traces ?

     

     

  • You could use sp_humanevents (Erik Darling) https://www.erikdarlingdata.com/sp_humanevents/

    To capture the waits while it is slow or log it to a table

    Tools like sp_Blitz, sp_Blitzfirst (Brent Ozar) to have a quick check on the server https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit Newsletter: https://www.brentozar.com/blitz/

    There is also a tool that captures the sqlstatements

    https://github.com/spaghettidba/XESmartTarget

    Saw a demo of it on dataminds and looked promising for lightweight monitoring

    Is the testserver up to date with patches ?

    • This reply was modified 2 years, 1 month ago by  Jo Pattyn. Reason: added XESmartTarget
  • bobrooney.81 wrote:

    Ed B wrote:

    Do you have 15-20 3TB databases on a test server and one of the databases is production?

    How much storage do you have? It sounds like you have 30-60 TB in databases. Is it possible you are running out of space? Are all the databases accessing the same volume(s)?

    We use EC2 instances in AWS and it is cheaper to create one large volume, but I think it leads to slow disk access, especially if tempdb is on the same volume.

    On Prod we have 1 copy of the database.

    All servers and storage is Microsoft Azure and Azure storage.

     

    If the Sql Server and Databases are in Azure each database can be individually sized based on performance requirements.

  • Few best practices to optimize SQL DB performance

    - Reduce Table Size

    - Simplify Joins

    - Use SELECT Fields FROM Instead of SELECT * FROM

    - Use EXISTS() Instead of COUNT()

    - Use WHERE Instead of HAVING

    - Add EXPLAIN to the Beginning of a Query

    - Create SQL Server Indexes

    - Avoid Running Queries in a Loop

    Best of luck

  • Hello,

    You can also run the query here for a general sense of what SQL Server is waiting on:

    SQL Server Wait Statistics (or please tell me where it hurts…)

    https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/

    HTH.

    -- webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • Since you are on 2017 pressumably , navigate to your database (in explorer) and drill down to the Query Store. There you will find the most expensive queries by cpu time, IO, and I would pay attention to any regressed queries as well. These are candidates for optimising.

     

    ----------------------------------------------------

  • Techno-Umesh wrote:

    Few best practices to optimize SQL DB performance

    - Reduce Table Size - Simplify Joins - Use SELECT Fields FROM Instead of SELECT * FROM - Use EXISTS() Instead of COUNT() - Use WHERE Instead of HAVING - Add EXPLAIN to the Beginning of a Query - Create SQL Server Indexes - Avoid Running Queries in a Loop

    Best of luck

    Having applies to a group not individual rows like a Where clause, so two different operators. Exists instead of Count ? Plus, How do you reduce the table size? Business requirements drive this and you have to have things optimized despite the table size.

     

    ----------------------------------------------------

  • bobrooney.81 wrote:

    Hi SQL Gurus,

    One of our production database is running very slow. I checked blocking , I didn't see any blocking. Also, check for running processes and look for any waittype. I see null. How to get more insights on a running sql server for a specific databases?

    What all can he checked in this scenario?

    Also, How to check what are the most or top 3-5 databases which are currently active on the server? any query please share and on what columns do we need to aggregate to check to see the top 5 dbs active at this point of time and taking up resources.

    This is a shared SQL instance and many dbs are hosted on it. each of 3TB in size. We have like 15-20 dbs hosted on that instance. Its a testing server. it has 16cpus and 256 gb RAM. SQL Server 2017 Enterprise Edition.

    Kind Regards,

    Bob

    Production servers should always be on their own box.  Development boxes can be had for a proverbial song because you can use the Developers Edition on those.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 13 posts - 1 through 12 (of 12 total)

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