Oracle sequence caching

前端 未结 3 762
心在旅途
心在旅途 2021-02-15 18:22

I am trying to implement a sequence in an Oracle database to act as a surrogate key creator for a table. For performance reasons, I want this sequence to be cached. I have rea

3条回答
  •  醉酒成梦
    2021-02-15 18:57

    No, this will not be the case.

    Your sequence will continue at 101, the values between 50 and 100 will be missing.

    The only reason to disable sequence caching is when trying to avoid gaps in your sequence, which is not relevant for most Primary Keys.

    You might be interested in this article, which states that

    The downside of creating a sequence with a cache is that if a system failure occurs, all cached sequence values that have not be used, will be "lost". This results in a "gap" in the assigned sequence values. When the system comes back up, Oracle will cache new numbers from where it left off in the sequence, ignoring the so called "lost" sequence values.

提交回复
热议问题