Sequence cache question

if there is a sequence with CACHE 20, are numbers that are allocated from the cache going to be ordered?. So if I have values 61..80 in the sequence cache, is the next NEXTVAL call GUARANTEED to get 61, or will it get any random value from the cache
thanks

In a RAC environment, by default, sequence values can be returned out of order. There is an ORDER attribute that can be added to he DDL to create a sequence to force sequence values to be returned in order (though I'd wager this has a decent performance cost).
In a single instance database, sequence values will be returned sequentially whether the sequence is created as ORDER or NOORDER.
Of course, even if sequences come in order, it's possible that when you have concurrent transactions, the one with the later sequence value manages to commit before the one with the earlier sequence value. This may or may not be a concern in your environment.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • Sequence caching with toplink and oracle caching

    Hi,
    In my application, I use toplink as a JPA provider. For performance reasons, I defined an allocationSize on sequence generator for some persistence objects. I read some documentation to understand how it works, the result of my research is that the allocationSize of sequence generator must match with the increment value of the sequence in database.
    So if I want to cache 1000 of values, I must define on my sequence generator allocationSize of 1000 and create a sequence like this : create sequence myseq increment by 1000. Am I right ?
    Second question, what if my sequence define a cache in the database. For example, create sequence myseq increment by 1000 cache 20.
    Does it mean that 20 values will be cached or 1000*20 values will be cached ? Is the cache size defined per session or for all the sessions of the database ?
    Thanks.
    Will.

    Thank you for your response.
    I used the default parameter of toplink (increment by 50) and I left a cache size of 20 on database side.
    But I noticed that whenever the server restarts, I "lost" between 900 and 1000 ids (nearly 20*50). So even if sequence cache on oracle size is non transactional, I think there is a kind of prefetch somewhere on the server side. I must not lost more than 50 ids when a server restarts.
    If I remove the cache on database side, then the behavior is correct (the expected one to be more precise).
    Is there any kind of sequence caching in oracle jdbc drivers ?
    Thanks.
    Will.

  • Oracle 10g sequence cache aging

    I have been reading some about how sequences work and why you can end up with gaps in the sequence numbers. It is my understanding that you could 'lose' certain sequence numbers when the library cache ages/expires. What I can't find is where this cache is configured. Where do you define when the cache will expire and thus clear out? Seems like it's happening very quickly in one of our databases, but much more slowly in another. Don't know where to look for this setting. Can anyone help point me in the right direction? Thanks!

    - The size of the sequence cache is driven by the CACHE parameter (default 20) when you create the sequence
    - Oracle manages the library cache automatically-- there are no parameters to set here for the timeout. When a particular object is aged out is going to depend on, among other things, the size of the library cache, the frequency a particular object is used, and the number of other objects competing for space in the library cache. If one sequence is constantly being used, it will stay in the library cache much longer than the cache for a less frequently used sequence. If one database's library cache is under pressure because you're constantly loading new objects, cached objects will be aged out far more quickly than in a database where the library cache is not under pressure.
    Justin

  • SEQUENCE CACHE

    제품 : ORACLE SERVER
    작성날짜 : 2003-08-04
    Sequence Cache
    오라클 sequence를 사용할 때에 cache라는 옵션을 가지고 있다.
    이러한 옵션을 사용할때 가끔 수자가 이어지지 않고 끊어지는 경우가 발생할 수
    있는데 여기서는 어떤 상황에서 수자가 없어지며 이러한 상황을 최소화할수 있는
    방법을 찾아보고자 한다.
    non-cache mode 인 경우에 'nextval' 을 요구하게 되면 current value에서 increment
    만큼의 값이 증가될 것이다. 예를 들어 current value는 0이고 increment는 1이며
    cache가 아닐 때 'nextval'을 요구하게 되면 1이 return 될 것이다.
    cache option과 같이 사용될 때 sequence에 대해서 'nextval'을 요구하게 되면
    cache 되는 만큼의 값에서부터 차례대로 next 값을 가져오게 되며 cache된 값을
    모두 사용하고 난 다음은 다음 caching 을 하게 된다.
    만약 다음과 같이 sequence가 선언되었다고 하자.
    create sequence seq increment by 1 cache 5;
    NUMBER SEQUENCE CACHE
    RETURNED CURRENT CURRENT
    start none 0 none
    1st access 1 5 1
    2nd access 2 5 2
    3rd access 3 5 3
    4th access 4 5 4
    5th access 5 5 5
    6th access 6 10 6
    7th access 7 10 7
    cache되어 있는 값들이 절대로 없어지지 않는다고 가정하면 출력되는 결과 값들은
    non-cache 의 그것과 다를 것이 없을 것이다.
    그러나 sequence cache도 역시 다른 cached information과 같이 shared pool 에 저장된다.
    이것은 다른 shared pool에 있는 procedure처럼 자주 access 되지 않으면 age out될 수
    있음을 의미하기도 한다. 또한 shutdown 시에는 cache에 있는 모든 것을 잃어버리게
    된다. 여기서 주로 shutdown에 의해 sequence의 번호가 skip 될수 있으므로 skip되어서는
    안되는 번호를 가진 응용프로그램에서는 non-cached sequence 를 사용해야 한다.
    다음에는 cache age out과 shutdown이후에 sequence number의 변화를 예를 들어 설명한다.
    NUMBER SEQUENCE CACHE
    RETURNED CURRENT CURRENT
    start none 0 none
    1st access 1 5 1
    2nd access 2 5 2
    cache aged out
    3rd access 5 10 5
    4th access 6 10 6
    shutdown
    5th access 10 15 10
    6th access 11 15 11
    7th access 12 15 12
    aging 문제를 해결하기 위해서 7.3 이후에서 부터는 dbms_shared_pool 이라는 package 를
    이용해서 shared pool내에 다음과 같이 고정시켜 놓을수 있다.
    dbms_shared_pool.keep('seq','Q');
    Reference Documents
    <Note:62002.1>

    제품 : ORACLE SERVER
    작성날짜 : 2003-08-04
    Sequence Cache
    오라클 sequence를 사용할 때에 cache라는 옵션을 가지고 있다.
    이러한 옵션을 사용할때 가끔 수자가 이어지지 않고 끊어지는 경우가 발생할 수
    있는데 여기서는 어떤 상황에서 수자가 없어지며 이러한 상황을 최소화할수 있는
    방법을 찾아보고자 한다.
    non-cache mode 인 경우에 'nextval' 을 요구하게 되면 current value에서 increment
    만큼의 값이 증가될 것이다. 예를 들어 current value는 0이고 increment는 1이며
    cache가 아닐 때 'nextval'을 요구하게 되면 1이 return 될 것이다.
    cache option과 같이 사용될 때 sequence에 대해서 'nextval'을 요구하게 되면
    cache 되는 만큼의 값에서부터 차례대로 next 값을 가져오게 되며 cache된 값을
    모두 사용하고 난 다음은 다음 caching 을 하게 된다.
    만약 다음과 같이 sequence가 선언되었다고 하자.
    create sequence seq increment by 1 cache 5;
    NUMBER SEQUENCE CACHE
    RETURNED CURRENT CURRENT
    start none 0 none
    1st access 1 5 1
    2nd access 2 5 2
    3rd access 3 5 3
    4th access 4 5 4
    5th access 5 5 5
    6th access 6 10 6
    7th access 7 10 7
    cache되어 있는 값들이 절대로 없어지지 않는다고 가정하면 출력되는 결과 값들은
    non-cache 의 그것과 다를 것이 없을 것이다.
    그러나 sequence cache도 역시 다른 cached information과 같이 shared pool 에 저장된다.
    이것은 다른 shared pool에 있는 procedure처럼 자주 access 되지 않으면 age out될 수
    있음을 의미하기도 한다. 또한 shutdown 시에는 cache에 있는 모든 것을 잃어버리게
    된다. 여기서 주로 shutdown에 의해 sequence의 번호가 skip 될수 있으므로 skip되어서는
    안되는 번호를 가진 응용프로그램에서는 non-cached sequence 를 사용해야 한다.
    다음에는 cache age out과 shutdown이후에 sequence number의 변화를 예를 들어 설명한다.
    NUMBER SEQUENCE CACHE
    RETURNED CURRENT CURRENT
    start none 0 none
    1st access 1 5 1
    2nd access 2 5 2
    cache aged out
    3rd access 5 10 5
    4th access 6 10 6
    shutdown
    5th access 10 15 10
    6th access 11 15 11
    7th access 12 15 12
    aging 문제를 해결하기 위해서 7.3 이후에서 부터는 dbms_shared_pool 이라는 package 를
    이용해서 shared pool내에 다음과 같이 고정시켜 놓을수 있다.
    dbms_shared_pool.keep('seq','Q');
    Reference Documents
    <Note:62002.1>

  • Sequence caching with oracle

    Hi,
    In my application, I use toplink as a JPA provider. For performance reasons, I defined an allocationSize on sequence generator for some persistence objects. I read some documentation to understand how it works, the result of my research is that the allocationSize of sequence generator must match with the increment value of the sequence in database.
    So here is my question, what if my sequence define a cache in the database ? For a cache of 1000 values on the application (or server) side, I can create a sequence like this : sequence myseq increment by 1000 cache 20.
    Does it mean that 20 values will be cached or 1000*20 values will be cached ? Is the cache size defined per session or for all the sessions of the database ?
    Thanks.
    Will.

    ok.... so if my sequence starts with 10000 and has a cache of 5, values from 11000 to 15000 will be cached, not values from 10000 to 100020 ?"5" values will be cached. You will find the following example to be helpful.
    [cache]
    SQL> create sequence myseq start with 10000 cache 5;
    Sequence created.
    SQL> select increment_by, cache_size, last_number from user_sequences where sequence_name = 'MYSEQ';
    INCREMENT_BY CACHE_SIZE LAST_NUMBER
    1 5 10000
    SQL> select myseq.nextval from dual;
    NEXTVAL
    10000
    SQL> /
    NEXTVAL
    10001
    SQL> /
    NEXTVAL
    10002
    SQL> /
    NEXTVAL
    10003
    SQL> /
    NEXTVAL
    10004
    SQL> select increment_by, cache_size, last_number from user_sequences where sequence_name = 'MYSEQ';
    INCREMENT_BY CACHE_SIZE LAST_NUMBER
    1 5 10005
    SQL> select myseq.nextval from dual;
    NEXTVAL
    10005
    SQL> select increment_by, cache_size, last_number from user_sequences where sequence_name = 'MYSEQ';
    INCREMENT_BY CACHE_SIZE LAST_NUMBER
    1 5 10010
    SQL>
    Asif Momen
    http://momendba.blogspot.com

  • Increase sequence cache - DWH Environment

    Hello everyone,
    I am writing to ask a question on the sequences.
    We work on a RAC with two nodes.
    We have some sequences, highly used by several job.
    The cache of these sequences is set with the default value.
    We would increase the performance of access to the sequences.
    Is it worth it?
    How can we make an estimate on the correct or most plausible value of the cache?
    Thanks
    Greetings
    Sandro

    Hi,
    It all depends on how are you using the sequences. You need to think about two main points: ordering and caching. Do the sequences MUST be ordered? If that's true than those sequences have to be created using ORDER and NOCACHE clauses but this will lead to poor performance on a RAC environment because you will increase the overhead to maintain consistency about the sequence. If the sequences don't need to be ordered and you can have different numbers accross the instances, than you should use NORDER and CACHE for best performance.
    Take a look at the doc in MOS Doc 853652.1 (RAC and Sequences)
    Regards.

  • Sequence cache (can it cause lock when.....)

    it is set to 0?
    We have a sequence that is used as a key in a table. If many users try to select next val from it at once and the cache is 0, can this cause the application to lock?
    (I know this sounds far fitch but the only question not ask is a stupid question)

    I would also ask why you were setting a sequence to
    NOCACHE if there is the potential for many users to
    access it simultaneously. Frequently used sequences
    ought to have appropriately sized caches.
    Folks that set sequences to NOCACHE are frequently
    trying to prevent gaps in their sequences. While
    setting a sequence to NOCACHE will tend to decrease
    the probability of gaps, it will not eliminate them.
    If your application absolutely requires a gap-free
    e sequence, you cannot use Oracle sequences and you
    have to deal with the (significant) performance
    penalty of serializing all transactions on the next
    sequence value.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC
    It was not the idea of the dba here, but the application programmers (we should be shot for allowing them to tell us this). They did not believe us when we told them that the sequences would not roll back... I reset the cache to a number other than 0...
    Thanks all for the feedback

  • Sequence caching in RAC

    Hi All,
    Production server configuration is 4 node RAC. Version is 11.2.0.3. Linux Platform. We are using sequences in DB.
    I was reading some blogs on sequence working on RAC env. I came to know a sequence with cache noorder will improve the performance.But i have not seen how can we cache a sequence properly in RAC.Can you please let me know your suggestions for the below questions?
    When we create any sequence, how can we cache a sequence properly on 4 instances?
    How can we calculate the cache for each instance?
    How shall we know whether sequence is using or not?
    Thanks,
    Mani

    Production server configuration is 4 node RAC. Version is 11.2.0.3. Linux Platform. We are using sequences in DB.
    I was reading some blogs on sequence working on RAC env. I came to know a sequence with cache noorder will improve the performance.But i have not seen how can we cache a sequence properly in RAC.Can you please let me know your suggestions for the below questions?
    When we create any sequence, how can we cache a sequence properly on 4 instances?
    How can we calculate the cache for each instance?
    How shall we know whether sequence is using or not?
    The 'user' doesn't cache the sequence, Oracle does. Just specify the CACHE value when you create the sequence.
    Oracle will use the SAME cache value for each instance. So if the cache value is 20 one instance might cache 1-20, the next instance cache 21-40 and so on. When an instance needs more values it will get the next set of 20 values that are available for that sequence.
    Which 'cache' gets used depends on which instance a query runs on. A query that executes on instance #2 will use the cache on instance #2.

  • Switching From Windows To Mac: ACR Database, Bridge Cache Questions

    I am planning to switch from Windows XP to the Mac running Leopard. I am now running CS2 in Windows, but will upgrade to CS3 on the Mac. I am maintaining my RAW file settings in ACR central database and my Bridge cache in a centralized cache file. I've searched the forums but couldn't find answers to my migration questions:<br /><br />1. Can one move the ACR database file from Windows (in folder C:\Documents<br />and Settings\<username>\Application Data\Adobe\CameraRaw) to a folder<br />somewhere on the Mac to preserve the settings on RAW files that are also<br />moved to the Mac? Or does one need to export individual XMP files for the<br />RAW files in Windows and move both the RAW files and their associated XMP<br />files to the Mac?<br /><br />2. I have a similar question for migrating the Bridge cache from Windows XP<br />to the Mac. Can one somehow move the Bridge cache over (I think it's in<br />C:\Documents and Settings\<username>\Application Data\Adobe\Bridge\Cache\Thumbnails\) or do I need to export the cache for<br />each folder and subfolder and move them over along with the folders and<br />subfolders?<br /><br />I would appreciate any help or pointers to any Adobe documents or<br />directions. Thank you.

    Man-Kong,
    Since you said that you were also migrating from CS2 to CS3 I would have said that their cache files were incompatible. That is what I experienced with CS1, CS2, and CS3 in the past. But Thomas indicated it should work. I must be missing something.
    The XMP files move fine for me. The local cache (folder) files have completely different names with each version and I see no evidence that they can be shared. This is also a problem with archived CDs. CS3 always has to rebuild cache if they were archived from CS1 or CS2.
    Since the central cache must have some folder references, and this structure will be completely different on Mac, I dont see how it can work. It doesnt work for scripts or actions either.
    So my humble recommendation is to set your preferences to store cache and XMP files in the local folders where possible. Then simply bite the bullet. Each time you visit a folder for the first time in the new environment, cache will be rebuilt.
    Cheers, Rags :-)

  • Captivate 7, sequencing quiz question, answers are not reshuffled

    Hello,
    I have made a quiz using Cp7. The questions are all sequencing questions. The first time around, the answers are shuffled, as one would expect. Then the quiz-taker puts the answers in the correct order. However, the following times the quiz-taker does the quiz, the answers aren't shuffled! So if the quiz-taker gets Question 1 right the first time, when he or she tries the quiz again, the answers for Question 1 are in the right order when the question first opens.
    Does anyone know what's going on here?
    Thank you. Marvin DuBois

    Thank you again. And yes, I should make a formal request.
    I might just mention that I've found something of a work-around. (This won't be news to you, but others in the same boat as myself might appreciate this.) Note that this works within a very specific context, so it is by no means a complete solution. But here goes.
    We run the Cp quizzes in an LMS (and that means, of course, a specific LMS). The solution works in this context. When making up a Cp quiz, I add a regular (non-question) slide after the score slide. On this slide I put a button that opens a webpage via a URL. And this URL is for the quiz itself--i.e. it is the LMS's address for the quiz. Thus, clicking the button simply restarts the quiz all over again, and this takes care of the randomization issues.
    This solution has two major drawbacks:
    1.The resume option has to be off.
    2.The Cp quiz itself cannot keep track of the attempts at doing the quiz (since with each new retake, the counting restarts at '1').
    I don't like having to do without the resume function. But in our particular case, the second issue isn't all that important. The LMS itself tracks the attempts at taking the quiz, so this information is always available both to quiz-takers and to administrators/teachers. (On the score slide itself, I simply remove the fields for the number of attempts.)
    At the moment, I'm trying to come up with a solution that would allow us to retain the resume function. So far, no luck, but we'll see.
    Best regards,
    Marvin DuBois

  • Sequence settings question

    I recently learned that whenever exporting a Quicktime file via the Quicktime Conversion method and selecting the NONE compression setting, that recompression occurs, although the selection indicates NONE (go figure). If I want to export a sequence, what selection should I use. And also, what about the Quicktime Video settings in the Sequence Settings dialogue box? What selection should I use when editing in, say, uncompressed 10bit or 8bit?
    I'm a little confused. Maybe there is an article or something out there that explains all the differences in Quicktime that someone knows about.
    Thanks, as usual, for all the help.
    Van
    G5 Dual 2Ghz    

    In a recent post, I was asking about a workflow issue I was having and the question came up. Instead of nesting a sequence, I exported it as a Quicktime movie using the Quicktime Conversion selection rather than the self-contained movie option and re-imported it, and I was concerned about any quality loss I might be introducing by doing it that way. In the "Conversion" dialogue box, you can select the codec, and I was selecting NONE. I was told not to use that setting because it recompressed the footage.
    The original sequence I was exporting was uncompressed 8bit, and the original footage was d-beta captured as NTSC 8bit.

  • Oracle 11g - Sequence Caching

    From the oracle documentation, http://docs.oracle.com/cd/E11882_01/server.112/e10701/original_export.htm#BABJHCDH
    it says that sequence numbers that have been allocated are available for use in the current database.
    I have a table Test which has a column test_id having a sequence test_sequence.
    Max value in the test_id is 20 and assume if test_sequence is cached for 20 in a 2 RAC node with each node caching numbers from 20-30 and 30-40.
    If I do an export and import the sequences to a new database, will my next sequence number in the new database be 41 ?
    If so, what will be the LAST_NUMBER in the dba_Sequences table in the source database.
    Thanks in advance.

    Hi,
    if you set CACHE 20 in a RAC environment each node will cache 20 number. In your case - cached numbers will be 21-40 and 41-60 and the dba_sequences.last_number=60.
    If you do export/import all the cached numbers will be lost and your first number will be last_number+1.

  • Sequence - cache size ?

    I created my sequence to increment by 1 with a default cache size of 20. This works fine as long as all my entries are done in the same session ( n + 1, n + 1... and so on). However, when I exit/return to my app the new sequence begins like: Last n + 20, n + 1, n + 1. . . and so on. Is it possible to reduce the cache size of a sequence?

    Leo,
    Please see this post:
    Sequence problem
    Particularly, Tom Kyte's explanation here:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:530735152441
    Thanks,
    - Scott -

  • Cache Question

    Hello all,
    I am not new to working with java (not writing it, just supporting it), but I'd like to know a little about this:
    I am currently working with a Java applet displaying TIF images that have been uploaded from another server. My question is about the Java cache. First of all, is it easy to find in the dir's? Everytime my applet loads a TIF image, what kind of files are being downloaded into the cache folder? What happens when cache folder has reached the maximum limit of memory that I have set? At that point, are files replaced with the current ones being downloaded, or is the cache no longer able to store files?
    I've been wondering this for some time now, so any help would be appreciated. Thanks!
    -adam

    ajetrumpet wrote:
    If you have a bad day, please don't respond. That's only fair to everyone, ya know?
    Thanks for the replies, or lack thereof, but I think this thread is pretty much useless now...thanks again for anything you guys helped with.I've had a great day, thanks, but if you look at this thread through the eyes of most of us here, you're coming off, well, not looking so good, kind of (and I hate to say it) like a spoiled brat. Is that how you want to appear? Seriously, think on how your reply will appear to others, not just the person you're arguing with. This is being posted with the intention of helping you get better answers in the future. Also, read this link here that tells you how to ask decent questions, questions that others will want to answer: [How To Ask Questions The Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html]
    good luck.

  • Cfquery caching question

    I have a question (actually two) about how caching works with cfquery so I can make sure that what I'm doing on our website makes sense. (We're on CF10)
    I have a database that stores certain details about each of the web pages on our site.  Contact ID, title, date added/updated, whether it's a recent or featured item, etc.  The unique identifier for each page is the path (/folder/subfolder/page.cfm).  Since out site is organized in several major topic areas, there's a column to identify which topic the page is in (and that's the same as the folder name that set of pages resides in).
    Some or topics get tons of hits, and some get very few, so I've been doing this:
    <cfquery name="getalltopics" datasource="dsn" cachedwithin="#createtimespan(0,1,0,0)#">
    SELECT (columns I need
    FROM pages
    WHERE topic = <cfqueryparam value="#topicname#"  cfsqltype="cf_sql_varchar">
    </cfquery>
    <cfquery name="getpagedetails" dbtype="query">
    SELECT (columns I need)
    FROM getalltopics
    WHERE page_id = <cfqueryparam value="#page_path#"  cfsqltype="cf_sql_varchar">
    </cfquery>
    So here's my question.  I know that caches only come into play if the query that's being run identically matches the one that's cached. So in my mind, the fist query would make an individual cache of each of our topics, as the pages were viewed during the day.  My second cache would grab the page details from the first, with several topics cached, how would the second one know which cache to find the page details in?  The query works, and is fast, but I'm just wondering if I need to specify the topic ID in the second query.
    My second question is about cache time.  If I do createtimespan(0,1,0,0), does that cache last for an hour after it's created, or does it last for an hour after the last time that query is run?
    Thanks!

    What I ended up doing was creating a variable-based query name, named after the current topic, like so:
    <cfset qname = "q" & topic_name>
    <cfquery name="#qname#" datasource="dsn" cachedwithin="#createtimespan(0,1,0,0)#">
    SELECT (columns I need)
    FROM pages
    WHERE topic = <cfqueryparam value="#topicname#"  cfsqltype="cf_sql_varchar">
    </cfquery>
    <cfquery name="getpagedetails" dbtype="query">
    SELECT (columns I need)
    FROM #qname#
    WHERE page_id = <cfqueryparam value="#page_path#"  cfsqltype="cf_sql_varchar">
    </cfquery>
    This way I (in theory) have a unique cache for each topic, and my second query draws from that cache.
    Upon implementation, I've noticed a significant reduction in database hits (since we still use Access on this site, any hit creates an .ldb file, so I can easily tell if it's getting hit).  Prior to the change, the ldb file was basically continuously there, appearing and reappearing a few times per second.  Now, several minutes can go by with no ldb, even at the peak of the day, and pages are getting rendered almost instantly.  If I add up all my query execution times for a page, I'm getting 5-7 ms total.
    So it has to be doing something.

Maybe you are looking for