分析数据库表和使用情况

发布于 2024-12-09 02:17:42 字数 114 浏览 0 评论 0原文

我刚进一家新公司,我的任务是优化数据库性能。一种可能的(也是建议的)方法是使用多台服务器而不是一台。由于有很多可能的方法可以做到这一点,我需要首先分析数据库。有没有一种工具可以测量每个表执行了多少插入/更新和删除?

I just got into a new company and my task is to optimize the Database performance. One possible (and suggested) way would be to use multiple servers instead of one. As there are many possible ways to do that, i need to analyse the DB first. Is there a tool with which i can measure how many Inserts/Updates and Deletes are performed for each table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如此安好 2024-12-16 02:17:42

我同意 Surfer513 的观点,即 DMV 将比 CDC 好得多。添加CDC相当复杂,并且会增加系统的负载。 (请参阅我的文章 此处用于统计。)

我建议首先设置一个 SQL Server Trace 以查看哪些命令长时间运行。

如果您的系统大量使用存储过程(希望如此),还请查看 sys.dm_exec_procedure_stats。这将帮助您专注于最常用的过程/表/视图。查看execution_count 和total_worker_time。

关键是您想要确定系统的哪些部分速度较慢(使用 Trace),以便您知道把时间花在哪里。

I agree with Surfer513 that the DMV is going to be much better than CDC. Adding CDC is fairly complex and will add a load to the system. (See my article here for statistics.)

I suggest first setting up a SQL Server Trace to see which commands are long-running.

If your system makes heavy use of stored procedures (which hopefully it does), also check out sys.dm_exec_procedure_stats. That will help you to concentrate on the procedures/tables/views that are being used most-often. Look at execution_count and total_worker_time.

The point is that you want to determine which parts of your system are slow (using Trace) so that you know where to spend your time.

匿名的好友 2024-12-16 02:17:42

一种方法是利用更改数据捕获 (CDC) 或更改跟踪 。不确定你要寻找的深度有多深,但还有其他更简单的方法来获得粗略的估计(看起来你不需要精确的数据,只是大概的数字......?)。

假设您的表上有索引,您可以查询 sys.dm_db_index_operational_stats 来获取影响索引的插入/更新/删除数据。再次强调,这是一个粗略的估计,但它会给您一个不错的想法。

One way would be to utilize Change Data Capture (CDC) or Change Tracking. Not sure how in depth you are looking for with this, but there are other simpler ways to get a rough estimate (doesn't look like you want exacts, just ballpark figures..?).

Assuming that there are indexes on your tables, you can query sys.dm_db_index_operational_stats to get data on inserts/updates/deletes that affect the indexes. Again, this is a rough estimate but it'll give you a decent idea.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文