Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequence cache and performance

I could see the DBA team advises to set the sequence cache to a higher value at the time of performance optimization. To increase the value from 20 to 1000 or 5000.The oracle docs, says the the cache value,

Specify how many values of the sequence the database preallocates and keeps in memory for faster access.

Somewhere in the AWR report I can see,

select SEQ_MY_SEQU_EMP_ID.nextval from dual

Can any performance improvement be seen if I increase the cache value of SEQ_MY_SEQU_EMP_ID.

My question is:

Is the sequence cache perform any significant role in performance? If so how to know what is the sufficient cache value required for a sequence.

like image 601
Nidheesh Avatar asked Jun 19 '14 04:06

Nidheesh


People also ask

What does CACHE do in sequence?

The sequence cache size determines how many values Oracle preallocates in memory, in the Shared Pool. By preallocating values, Oracle returns the next unique value from memory providing faster access to the information.

How do you increase CACHE size in a sequence?

Once you have determined the active tables and layers in your instance, you need to increase the cache size value. You can do this with the following command in SQL*Plus: ALTER SEQUENCE r10 cache 1000; The next time the sequence is referenced by an application, Oracle will place in memory a range of 1000 values.

What is CACHE in SQL sequence?

The cache is maintained in memory by tracking the current value (the last value issued) and the number of values left in the cache. Therefore, the amount of memory used by the cache is always two instances of the data type of the sequence object.

What is CACHE in Create sequence?

The "cache" clause caches the specified number of sequence values into the buffers in the SGA. This speeds access, but all cached numbers are lost when the database is shut down. The default value is 20; maximum value is maxvalue-minvalue.


2 Answers

We can get the sequence values from oracle cache before them used out. When all of them were used, oracle will allocate a new batch of values and update oracle data dictionary. If you have 100000 records need to insert and set the cache size is 20, oracle will update data dictionary 5000 times, but only 20 times if you set 5000 as cache size.

More information maybe help you: http://support.esri.com/en/knowledgebase/techarticles/detail/20498

like image 195
VikiYang Avatar answered Sep 21 '22 14:09

VikiYang


If you omit both CACHE and NOCACHE, then the database caches 20 sequence numbers by default. Oracle recommends using the CACHE setting to enhance performance if you are using sequences in an Oracle Real Application Clusters environment.

Using the CACHE and NOORDER options together results in the best performance for a sequence. CACHE option is used without the ORDER option, each instance caches a separate range of numbers and sequence numbers may be assigned out of order by the different instances. So more the value of CACHE less writes into dictionary but more sequence numbers might be lost. But there is no point in worrying about losing the numbers, since rollback, shutdown will definitely "lose" a number.

CACHE option causes each instance to cache its own range of numbers, thus reducing I/O to the Oracle Data Dictionary, and the NOORDER option eliminates message traffic over the interconnect to coordinate the sequential allocation of numbers across all instances of the database. NOCACHE will be SLOW...

Read this

like image 42
SriniV Avatar answered Sep 19 '22 14:09

SriniV