解决数据库性能问题
我遇到了数据库问题,这是我每天都要处理的场景:通常应用程序可以处理流量等,但每天我都会处理几次性能问题。当发生这种情况时,存储过程的执行时间会从 200%-1000% 增加。
我有一个,如下所述: https://stackoverflow.com/questions/5585726 /query-with-large-table-joins-optimization-techniques 。通常它的执行需要大约 6-8 秒(我已经从 20 秒优化了它,因为一开始我认为该过程是罪魁祸首),但是当某事发生时,该过程甚至可以执行 60 秒。
今天,我意识到应用程序中有更多地方冻结了,而且,我意外地意识到,从 SQL Management Studio 发出的示例查询(通常在眨眼间执行)在某些情况下开始变慢 发生在数据库服务器上。好消息是,由于这一发现,我消除了应用程序和应用程序。 Web 服务器是瓶颈。
这是数据库服务器无法处理请求。我想知道是否有一种方法可以对实时数据库进行故障排除并发现缓慢的查询或其他操作,例如重建索引、统计数据、内存问题等,或者可能导致所描述的性能下降的其他问题?
谢谢,帕维尔
I've a problem with database, and here is a scenario I'm dealing with every day: usually application can deal with traffic etc. but several times a day I'm dealing with performance issue. When it's happening stored procedures increase their execution time from 200%-1000% .
I have one, described here: https://stackoverflow.com/questions/5585726/query-with-large-table-joins-optimization-techniques . Usually its execution takes about 6-8seconds (I've already optimized it from 20seconds cos at the beginning I thought the procedure is the culprit), but when something is happening, that procedure can execute even 60seconds.
And today I realized that there are more places in application that freeze, and what is more, I accidentaly realized that sample queries issued from SQL Management Studio, that usually execute in the blink of an eye, start to slow down when something happens with database server. Good news is, that thanks to this finding I eliminated both application & web servers as bottlenecks.
It's database server that's not able to handle requests. I wonder is there a way to troubleshoot live database and spot slow queries or other action like rebiulding indexes, statistics, memory problems etc. or perhaps other issues that could result in described performance decline?
Thanks, Pawel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我经常使用的查询。
它显示您当前正在执行的代码、等待信息、阻塞信息、正在运行哪些 spid、运行了多长时间、当前命令是什么、正在执行的命令是什么。查询文本为,以及 xml 查询计划(如果缓存中有):
This is a query that I use pretty much constantly.
It shows you currently executing code, Wait information, blocking information, what spids are running, how long they have been running, what the current command is, what the query text is, and the xml query plan if there is one in the cache:
在 SSMS 中,如果右键单击服务器名称(而不是数据库名称),它将显示一个“活动监视器”菜单,单击该菜单,这将是一个很好的起点。
In SSMS if you right click on the Server name (not DB name) it will show you an Activity Monitor menu, click that and it would be a good place to start.