You are on page 1of 5

Design

1. What is normalization and its types 2. What are ACID properties

ARCHITECTURE
1. 2. 3. 4. 5. is SGA,PGA,UGA is Shared pool, library cache, dictionary cache is buffer cache and redo log buffers are background processes are dirty buffers 6. constitute an Oracle instance? 7. is the function of checkpoint (ckpt)? 8. does dbwr write to the database ? 9. does lgwr write to the database ? 10. Undo management and UNDO_RETENTION 11. How to avoid snapshot too old error? 12. What is an Oracle Rollback Segment? 13. What does a Control file Contain? 14. Difference between db_name and db_unique_name 15. Difference between SID and service name 16. What are consistent gets/DB block gets and current mode gets? 17. Difference between Locks,Latches,Enquees? 18. What is logical IO? 19. Gets vs Readss What What What What What What What When When

What is normalization and its types What are ACID properties


ACID is a set of properties that guarantee that database transactions are processed reliably Atomicity requires that each transaction is "all or nothing" Consistency property ensures any data written to the database must be valid according to all defined rules, including but not limited to constraints, cascades, triggers, and any combination thereof. Isolation - Each transaction has to execute in total isolation of other transactions Durability- Committed transactions should never be lost even in case of power failures etc.

What is SGA,PGA,UGA
Program Global area (pga) is a memory buffer that contains data and control information for a server process.
The User Global Area (UGA) is memory that is associated with a user session. The UGA normally comes from the SGA to allow migration of sessions across processes. session migration is disabled, UGA memory will be allocated from the PGA.

If

The Process Global Area (PGA) is memory which is physically private to a process (cannot be accessed by another process). Note that an OS process and an Oracle session are not equivalent. The PGA, unlike the SGA, can grow at runtime. So, in dedicated server mode, when session migration is not needed, the UGA is in the PGA is in the individual process.

When does dbwr write to the database ?


Dbwr writes to data files when: when dirty buffers reach threshold (primary job ofr DBWR) more data needs to be read into the sga and too few database buffers are free. when checkpoint occurs, the Log Writer process (LGWR) signals DBWR to write. RAC ping request is made when any tablespace is taken offline,read only,drop or truncated & when begin backup when a timeout occurs (if DBWR is inactive for 3 seconds.)

When does lgwr write to the database ?


Lgwr writes redo log entries into an on-line redo log file when: when transaction commits every three seconds when 1/3 of redo full when the DBWR process writes modified buffers to disk

Undo management
Storing Undo Records Undo records can be stored in either rollback segments or undo tablespaces. Rollback Segment Undo Rollback segments have traditionally stored undo information used by several functions of Oracle. During database recovery, after all changes recorded in the redo log have been applied, Oracle uses rollback segment information to undo any uncommitted transactions. Because rollback segments are stored in the database buffers, this important recovery information is automatically protected by the redo log. UNDO_MANAGEMENT=MANUAL Automatic Undo Automatic undo management enables a DBA to exert control over how long undo records are retained before being overwritten. Automatic undo management mode is more efficient, and less complex to implement and manage than rollback segment undo. UNDO_MANAGEMENT=AUTO Managing Undo The UNDO_POOL directive enables DBAs to control runaway transactions by grouping users into consumer groups, with each group assigned a maximum undo space limit. Whenever the total undo space consumed by a group exceeds the limit, its users are not allowed to make any further updates, until undo space is freed up by other members (after their transactions commit or abort).

In addition to space management, a DBA can specify an UNDO_RETENTION period to minimise occurences of the "snapshot too old" error. You can set this at startup or with the ALTER SYSTEM statement. e.g. set retention to 20 minutes (1200 seconds): ALTER SYSTEM SET UNDO_RETENTION = 1200; An important caveat with this is that Oracle will not reuse space (wrap the rollback segment back around over itself) while there is an active transaction. So if you run a one hour long transaction and have a 20 minute retention - then the undo tablespace will still continue to grow for the whole hour. If the undo space is less than the longest running transaction, you will get a 'failure to extend' error and the transaction will fail and roll back. Even when the retention period has passed Oracle does not actively delete data from undo, it will simply be overwritten by the next transaction.

What is an Oracle Rollback Segment?


A Database contains one or more Rollback Segments to temporarily store "undo" information. Segments are used: To generate read consistent database information during database recovery to rollback uncommitted transactions for users

Difference between db_name and db_unique_name


The parameter db_unique_name specifies a name that uniquely identifies the databases in a Data Guard configuration. The DB_NAME for all standby databases must match the DB_NAME of the primary database. Each database must be giving a unique name by specifying DB_UNIQUE_NAME. This name stays with the database and does not change, even if the primary and standby databases reverse roles.

Difference between SID and service name


SID = unique name of the INSTANCE (eg the oracle process running on the machine). Oracle considers the "Database" to the be files. Service Name = alias to an INSTANCE (or many instances). The main purpose of this is if you are running a cluster, the client can say "connect me to SALES.acme.com", the DBA can on the fly change the number of instances which are available to SALES.acme.com requests, or even move SALES.acme.com to a completely different database without the client needing to change any settings.

What are consistent gets/DB block gets and current mode gets?
A 'db block get' is a current mode get. That is, it's the most up-to-date copy of the data in that block, as it is right now, or currently. There can only be one current copy of a block in the buffer cache at

any time. Db block gets generally are used when DML changes data in the database. In that case, row-level locks are implicitly taken on the updated rows. A 'consistent get' is when Oracle gets the data in a block which is consistent with a given point in time, or SCN. Explanation with example:

CurrentModeSession1.sql

CurrentModeSession2.sql

Difference between Locks,Latches,Enquees?


Latches and enqueues are both types of locks. Latches are lightweight serialization devices. We try to get a latch, spin for a bit and try again. So when getting a latch, we try and try and try -- we are not told that the latch is available, we keep trying to get it (eg: not necessary a first come, first serve lock). We use latches to serialize access to in memory data structures typically (like SGA data structures) We take the DBA (data block address) you are looking for and hash it to a number between 1 and number of arrays of lists in the cache. We then 'latch' that list so we can walk it and look for your block. Enqueues are heavyweight serialization devices. If we cannot get an enqueue, we "go to sleep" and when the enqueue is available -- we are told about it in a first come, first serve manner. We use enqueues to perform row level locking for example.

Discussion on Tom Kyte website:


hi tom, been scrolling through this page on latches and enqueues and come up with abit of own understanding on latches. as i understand - latches are low level serialization locks that protect data in memory structures from getting corrupted can i simply illustrate this as an example? UPDATE emp set sal = 50 where empid = 1234; Upon this 1) Since i need to update a block in the db buffer (which is a memory structure) can i said that that particular buffer is latched ? 2) once the latched for that buffer is obtained, an update to the row is done (with a lock status indicated in the row piece itself) this is what we call enqueue (higher level lock for transaction serialization purposes) 3) once the update is done, the latch is release

4) once the update is commmited the lock is release am i right ?

Followup July 14, 2009 - 2pm Central time zone:


1) no, you would say "the data structures that are used to hold the buffers are latched". That is, in the buffer cache there is an array of pointers to lists of blocks. In order to get a block out of one of these lists, we latch the list (cache buffers chains latch). We take the DBA (data block address) you are looking for and hash it to a number between 1 and number of arrays of lists in the cache. We then 'latch' that list so we can walk it and look for your block. To update the block, you would get it in current mode - only one transaction can get a block in current mode (an attribute of the block) at a time. 2) when you modify the block, you fill in the ITL (interested transaction list) information in the header. When someone else wants to update that block - they get the block and look to see if any ITL entries point to a row they want to modify. If they do - they look to see if that transaction is committed or not. If the transaction is committed - they continue one. Else, if the transaction is still open, then ENQUEUE (get in line) on that transaction. When it commits, they'll be released and can retry their modification. 3) the latch was long gone - you might get and release thousands of latches during the processing of the update. An update takes way too long to hold a latch for the entire duration of the statement. 4) the waiters will be released, yes

You might also like