如何在Oracle下处理大型事务? [英] How to handle large transactions under Oracle?

查看:985
本文介绍了如何在Oracle下处理大型事务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序基于Hibernate 3.5,Spring 3.1和Oracle下我不断遇到Max Cursors Exceeded问题,主要是在处理大型事务时(涉及的实体数量大,执行的查询数量)。在H2,MS SQL Server或MySQL上运行应用程序时不会出现此类问题。

Our application is based on Hibernate 3.5, Spring 3.1 and under Oracle I keep running into Max Cursors Exceeded issues, mainly when dealing with large transactions (large in terms of the number of entities involved, the number of queries executed). No such issues occur when running the application on top of H2, MS SQL Server or MySQL.

如果我已正确理解调查结果,Oracle会创建一个游标对于在事务期间构建的每个ResultSet,这些游标仅在连接上调用 close 时释放(即Hibernate会议)。

If I've understood the results of my investigations correctly, Oracle creates a cursor for every ResultSet built during a transaction, and these cursors are only released upon calling close on the Connection (i.e the Hibernate Session).

我的问题(暂时):


  1. 有没有办法让当
    交易正在进行时,Oracle会清理游标吗?有很多查询结果在事务中的特定点之后不需要
    ,但是
    Oracle似乎会保持游标打开。

  2. 是否存在正常最大光标设置?默认值为50,大部分为
    我们的客户设置了400-600个游标,但我见过的论坛帖子中的一些
    似乎表明几千元是
    更常见。当我们建议将最大游标数量增加到
    (比如5000)时,我们似乎也从我们的
    客户端DBA中获得了大量的回击。这真的是一件大事吗?

坦率地说,我读过的大部分论坛帖都与ResultSet / Statement / Connection泄漏有关,但是从我们的分析中我们没有它们;当我们关闭连接时,当前光标计数恢复正常。我们似乎是唯一一个在单个事务中尝试执行几百个操作的问题。这真的是这个异常吗?

Frankly, most of the forum posts I've read were to do with ResultSet/Statement/Connection leaks, but from our analyses we don't have them; the moment we close the connection, the current cursor count goes back to normal. We seem to be the only ones having issues with trying to perform a few hundred operations in a single transaction. Is that really this abnormal?

感谢您的任何建议;这个东西甚至让我的白发脱落

Thanks for any advice; this stuff is making even my gray hairs fall out

推荐答案

Oracle为每个结果集创建游标并在关闭结果集时释放它(jdbc ResultSet.close()或类似的)。对于任何设计良好的应用程序,默认情况下每个会话50个开放游标就足够了(一旦我测量它,在生产模式下它从未超过20个)。

Oracle creates cursor for every resultset and releases it upon closing the resultset (jdbc ResultSet.close() or similar). Default of 50 open cursors per session is enough for any well-designed application (once I measured it, and in production mode it never raised over than 20).

你应该检查如何使Hibernate在获取后关闭结果集。一般来说,如果真的需要1000个开放游标,我无法想象会话应该做什么。我从来没有看到max_open_cursors设置超过1000,所以,我想,它对于设计糟糕的应用程序来说也足够了(但是......在清醒的事实中没有完美的限制,我从不使用Hibernate)。

You should check how to make Hibernate to close resultsets after fetching. Generally, I cannot imagine what session should do if it really requires 1000 open cursors. I never saw max_open_cursors more than 1000 set, so, I guess, it's enough for bad-designed applications too (but... there is no limit for perfection in sober fact, and I never use Hibernate).

每个游标都意味着一些内存,因此增加max_open_cursors不是零价格的解决方法。

Every cursor means some memory, so increasing max_open_cursors is not zero-price workaround.

这篇关于如何在Oracle下处理大型事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆