有没有办法使用Hibernate从Java中监控数据库性能?

huangapple go评论76阅读模式
英文:

Is there a way to monitor database performance from java using hibernate?

问题

我使用 Hibernate,我的数据库可能会有很大的不同,MySQL,MSSQL,Oracle。我需要监控数据库的负载和/或性能,以实时获取数据库的状态。检查数据库的可用性相当容易,但如果您想要知道当前时刻数据库的负载情况,我对其实际用处存疑。

有没有办法做到这一点?也许有一些有用的替代方法?

英文:

I use hibernate and my database may be quite different, MySQL, MSSQL, Oracle. I need to monitor database load and/or performance to get the state of database in real time. Availability of the database is quite easy to check, but I doubt it is really useful if you want to know how loaded the database in the current moment.

Is there a way to do it? May be there are some useful alternatives?

答案1

得分: 2

所有你提到的数据库都通过SQL接口提供某种形式的统计数据和性能计数器。然而,在底层,它们完全不同,使用不同的专有概念。每个数据库都提供不同的性能计数器,以及一种不同的读取方式。如果不了解内部情况,这些数字对你来说将会完全毫无意义。要理解它们,你必须了解特定数据库的工作原理,而这可能意味着需要为每个数据库单独学习多年时间。这被称为“数据库管理员职业”。这些数据库都没有“负载程度”的概念,你必须根据你在你的情况下认为相关的数十(可能是数百)个计数器来得出结论。然而,无论你如何尝试以及使用哪些计数器来计算“负载程度”,MSSQL的值为10绝不会与Oracle的值为10相同。更糟糕的是,数据库内部情况(因此也包括性能计数器)在不同版本之间会发生 drastical 的变化。

底线:没有共同的基准,也永远不会有。试图比较它们就像在比较苹果和橙子。

话虽如此,它们每个都有自己的监控和优化工具。

英文:

All the databases you mentioned provide some kind of statistics and performance counters via SQL interface. Under the hood, however, they are completely different and use different, proprietary concepts. Each database provides different performance counters and also a different way of reading them. Without knowing the internals those numbers will look completely meaningless to you. To understand them you have to understand how that particular database works, and this can mean many years of study for each database separately. It's called a "DBA career". None of those databases has a concept of "how loaded" it is, and you will have to make that conclusion based on tens (possibly hundreds) of counters that you see as relevant in your case. Still, regardless of how you try and which counters you use for your calculation of "loadedness", a value of 10 for MSSQL will never be same as value of 10 for Oracle. To make things even worse, database internals (and thus also performance counters) change drastically between versions.

Bottom line: there is no common denominator, and there can never be. Trying to compare them is like comparing apples and oranges.

That said, each of them has its own tools for monitoring and optimization.

huangapple
  • 本文由 发表于 2020年8月19日 15:41:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/63482196.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定