Search code examples
asp.netoracle-databasesequences

Oracle sequence cache aging too often


my asp.net application uses some sequences to generate tables primary keys. Db administrators have set the cache size to 20. Now the application is under test and a few records are added daily (say 4 for each user test session). I've found that new test session records always use new cache portions as if the preavious day cached numbers had expired, losing tenth of keys everyday. I'd like to understand if it's due to some mistake i might have made in my application (disposing of tableadapters or whatever) or if it's the usual behaviour. There are programming best practices to take into account when handling oracle sequences ?

Since the application will not have to bear an heavy load of work (say 20-40 new records at day), i was tinking if it might be the case to set a smaller cache size or none at all. Does sequence cache resizing implies the reset of current index ?

thank you in advance for any hint


Solution

  • The answer from Justin Cave in this thread might be interesting for you:

    http://forums.oracle.com/forums/thread.jspa?threadID=640623

    In a nutshell: if the sequence is not accessed frequently enough but you have a a lot of "traffic" in the library cache, then the sequence might be aged out and removed from the cache. In that case the pre-allocated values are lost.

    If that happens very frequently to you, it seems that your sequence is not used very often.

    I guess that reducing the cache size (or completely disabling it) will not have a noticable impact on performance in your case (also when taking your statement of 20-40 new records a day into account)