Oracle:序列是如何实现的?

发布于 2024-08-01 15:24:39 字数 177 浏览 4 评论 0原文

为了满足一些奇怪的业务需求,我将不得不实现我自己的类似序列的计数器。 我将以显而易见的方式对此进行初步讨论,但我想更多地了解 Oracle 如何实现序列。 例如,他们可以使用闩锁而不是锁吗?

我在网上找不到太多相关信息,因此欢迎指向文档以及您个人经验的见解!

(10g RAC,如果重要的话)

To meet some odd business requirements, I'm going to have to implement my own sequence-like counters. I'm going to make a first cut of this in the obvious way, but I would like to understand a bit more about how Oracle implements sequences. For example, can they use latches instead of locks?

I've been unable to find much about this on the web, so pointers to docs as well as insight from your personal experience welcome!

(10g RAC, if it matters)

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

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

发布评论

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

评论(4

猫卆 2024-08-08 15:24:39

我不认为 Oracle 已经发布了序列的内部工作原理,但是 Jonathan Lewis 写了一些关于它们如何工作的详细分析 这里。 从该文件:

因为该机制是内部的
Oracle 非常高效
绕过正常的锁定争用
与传统出现的
最终用户编码的“序列a表”
序列对象:'给我下一个
可用号码”和“提醒我什么”
又是这样’; 这些是
nextvalcurrval 调用
分别。

下一个请求
去全局缓存获取
下一个可用序列值和
将其复制到会话的本地
内存。

I don't think Oracle has published the internal workings of sequences, but Jonathan Lewis has written some detailed analysis of how they work here. From that document:

Because the mechanism is internal to
Oracle it is very efficient and
bypasses the normal locking contention
that appears with the traditional
end-user coded ‘tables of sequence a
sequence object: ‘give me the next
available number’ and ‘remind me what
that was again’; these are the
nextval and currval calls
respectively.

The nextval request
goes to the global cache to get the
next available sequence value and
copies it to the session’s local
memory.

隱形的亼 2024-08-08 15:24:39

您想要/需要无间隙数字序列吗? 阅读以下内容: http:// Asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4343369880986

Do you want/need a gapless sequence of numbers? Read this: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4343369880986

只是一片海 2024-08-08 15:24:39

我认为您需要解释为什么您需要实现自己的序列。 如果我们知道您要解决的问题,我们也许可以给您答案,这样您就不必执行自己的自定义序列。

I think you need to explain why you would need to implement your own sequence. If we know the problem you are trying to solve we may be able to give you an answer so you would not have to do your own custom sequence.

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