Oracle 中的非活动会话
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26323678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Inactive sessions in Oracle
提问by Ali Immam
I would like to ask a question :
我想问一个问题:
This is my environment :
这是我的环境:
- Solaris Version 10; Sun OS Version 5.10
- Oracle Version: 11g Enterprise x64 Edition.
- Solaris 版本 10;Sun 操作系统 5.10 版
- Oracle 版本:11g 企业 x64 版。
When I am running this query :
当我运行此查询时:
select c.owner, c.object_name, c.object_type,b.sid, b.serial#, b.status, b.osuser, b.machine
from v$locked_object a , v$session b, dba_objects c
where b.sid = a.session_id
and a.object_id = c.object_id;
Sometimes I get many status to be 'INACTIVE'
.
有时我会得到很多状态'INACTIVE'
。
What does this inactive mean? Does this will make my db and application slow? What are the affects of active and inactive status?
这个不活动是什么意思?这会使我的数据库和应用程序变慢吗?活动和非活动状态的影响是什么?
回答by Jeff Holt
What does this inactive mean?
这个不活动是什么意思?
Just before the oracle executable executes a read
to get the next "command" that it should execute for its session, it will set its session's state to INACTIVE
. After the read
completes, it will set it to ACTIVE
. It will remain in that state until it is done executing the requested work. Then it will do the whole thing all over again.
就在 oracle 可执行文件执行 aread
以获取它应该为其会话执行的下一个“命令”之前,它将其会话的状态设置为INACTIVE
. 在后read
完成后,将其设置为ACTIVE
。它将保持该状态,直到完成执行请求的工作。然后它会重新做整个事情。
Does this will make my db and application slow?
这会使我的数据库和应用程序变慢吗?
Not necessarily. See the answer to your final question.
不必要。查看最后一个问题的答案。
What are the affects of active and inactive status?
活动和非活动状态的影响是什么?
The consequences of a large number of sessions (ACTIVE or INACTIVE) are significant in two ways.
大量会话(活动或非活动)的后果在两个方面很重要。
The first is if the number is monotonically increasing, which would lead one to investigate the possibility that the application is leaking connections. I'm confident that such a catastrophe is not the case otherwise you would have mentioned it specifically.
第一个是数字是否单调增加,这将导致人们调查应用程序泄漏连接的可能性。我相信不会发生这样的灾难,否则你会特别提到它。
The second, where the number fluctuates within the declared upper bound, is more likely. According to Andrew Holdsworthand other prominent members of the RWP, some architects allow too many connections in the application's connection pool and they demonstrate what happens (response time and availability consequences) when it is too high. They also have a prescription for how to better define the connection pool's attributes and behavior.
第二个,其中数字在声明的上限内波动,更有可能。根据Andrew Holdsworth和RWP 的其他著名成员的说法,一些架构师允许应用程序的连接池中的连接过多,并且他们演示了当连接池过高时会发生什么(响应时间和可用性后果)。他们也有关于如何更好地定义连接池的属性和行为的处方。
The essence of their argument is that by allowing a large number of connections in the pool, you allow them to all be busy at the same time. Rather than having the application tier queue transactions, the database server may have to play a primary role in queuing for low level resources like disk, CPU, network, and even other things like enqueues.
他们的论点的本质是,通过允许池中有大量连接,您可以让它们同时处于忙碌状态。数据库服务器可能必须在排队低级资源(如磁盘、CPU、网络,甚至其他事物(如入队))中扮演主要角色,而不是让应用程序层排队事务。
Even if all the sessions are busy for only a short time and they're contending for various resources, the contention is wasteful and can repeat over and over and over again. It makes more sense to spend extra time devising a good user experience queueing model so that you don't waste resources on what is undoubtedly the most expensive (hardware and software licenses) tier in your architecture.
即使所有会话都只忙了很短的时间并且它们正在争夺各种资源,但争用是浪费的,并且可以一遍又一遍地重复。花额外的时间设计一个良好的用户体验排队模型更有意义,这样您就不会在架构中无疑是最昂贵的(硬件和软件许可证)层上浪费资源。
回答by Trinimon
ACTIVE
means the session is currently executing some SQL operations whereas INACTIVE
means the opposite. Check out the ORACLE v$session
documentation
ACTIVE
表示会话当前正在执行一些 SQL 操作INACTIVE
,反之亦然。查看ORACLEv$session
文档
By nature, a high number of ACTIVE
sessions will slow down the whole DBMS including your application. To what extent is hard to say - here you have to look at IO, CPU, etc. loads.
本质上,大量ACTIVE
会话会减慢整个 DBMS,包括您的应用程序。很难说到什么程度——这里你必须看看 IO、CPU 等负载。
Inactive sessions will have a low impact unless you exceed the maximum session number.
除非超过最大会话数,否则非活动会话的影响很小。
回答by Lalit Kumar B
In simple words, an INACTIVE
status in v$session means no SQL statement is being executed at the time you check in v$session.
简单来说,INACTIVE
v$session 中的状态意味着在您签入 v$session 时没有正在执行 SQL 语句。
On other hand, if you see a lot of inactive sessions, then first check the last activity time
for each session.
另一方面,如果您看到许多非活动会话,则首先检查last activity time
每个会话的 。
What I suspect is that, they might be part of a connection pool
, hence they might be getting used frequently. You shouldn't worry about it, since from an application connection
perspective, the connection pool will take care of it. You might see such INACTIVE
sessions for quite a long time.
我怀疑的是,它们可能是 a 的一部分connection pool
,因此它们可能会经常使用。您不必担心,因为从一个application connection
角度来看,连接池会处理它。您可能INACTIVE
会在很长一段时间内看到此类会话。
回答by malay biswal
It does not at all suggest D/B is slow.
它根本不表明 D/B 很慢。
Status INACTIVE means session is not executing any query now. ACTIVE means it's executing query.
状态 INACTIVE 表示会话现在没有执行任何查询。ACTIVE 表示它正在执行查询。