Thread: Making SGA as big as possible always a good idea ?


Permlink Replies: 4 - Pages: 1 - Last Post: Aug 15, 2007 1:05 PM Last Post By: Jonathan Lewis
user590072

Posts: 122
Registered: 08/14/07
Making SGA as big as possible always a good idea ?
Posted: Aug 15, 2007 11:34 AM
Click to report abuse...   Click to reply to this thread Reply
Hello,

during trying to learn about oracle i came across the following question:

Lets say i have a rather small database, with all datafiles together not larger than 1GB. And lets assume further that this database should run on a server with 8GB of ram. So, the OS will take some part of the 8GB, but there will be a lot of space left.

Is there any reason for not making the SGA very big, like lets say 1GB ? I think i remember to have read about "lots of logical reads" as a reason for not "oversizing" the SGA at some place on the internet, but as i'm a beginner i may have got that wrong...
Hans Forbrich

Posts: 10,458
Registered: 03/13/99
Re: Making SGA as big as possible always a good idea ?
Posted: Aug 15, 2007 11:56 AM   in response to: user590072 in response to: user590072
Click to report abuse...   Click to reply to this thread Reply
There is a balance. Professional DBAs are trained to hunt for that balance.

Basically, Oracle does all data manipulation (select, insert, update, and delete) in memory. in block images.

Due to the Consistent Read model, SELECTs (even subselects or implied selects) may create 'Consistent Read' block images that reflect the stable state of the block when query started. This is done by taking an image of a block that is being updated, and applying the undo to that block.

(In other words, the SGA may have multiple copies of a specific block. Each copy represents a different point in time.)

Updated blocks in the SGA need to be 'backed-up' to the data files on disk. This will happen periodically (due to checkpoint) or on demand (SGA too small),

The process of determining which blocks need to be written to disk will take longer with a large SGA. As a result, it is possible that for some types of applications, increasing the SGA too much can actually slow down the application.

Due to enhancements in this area, the accuracy of statement and the impact of SGA size depends on the version of the database.
MarkDPowell

Posts: 4,054
Registered: 12/07/98
Re: Making SGA as big as possible always a good idea ?
Posted: Aug 15, 2007 12:00 PM   in response to: user590072 in response to: user590072
Click to report abuse...   Click to reply to this thread Reply
"Making SGA as big as possible always a good idea ?"

No, it can be a very bad idea. The SGA should be only as large as it needs to be.

Also the physical size of the database has very little relation to how large the SGA should be size. It is the user load and DML activity levels that demand SGA and PGA. I have seen sites force paging and swaping at the OS level because of over-allocation of the SGA where more space was need for PGA. With only a 1G database and 8G of physical memory the odds are you will not have that problem but the principal remains: size the SGA, PGA, etc... as appropriate.

HTH -- Mark D Powell --
user590072

Posts: 122
Registered: 08/14/07
Re: Making SGA as big as possible always a good idea ?
Posted: Aug 15, 2007 12:12 PM   in response to: user590072 in response to: user590072
Click to report abuse...   Click to reply to this thread Reply
Thank you very much for those infos!
Jonathan Lewis

Posts: 1,911
Registered: 01/23/07
Re: Making SGA as big as possible always a good idea ?
Posted: Aug 15, 2007 1:05 PM   in response to: Hans Forbrich in response to: Hans Forbrich
Click to report abuse...   Click to reply to this thread Reply
Hans,

In general, for versions frmo 8i onwards, the size of the buffer cache shouldn't make any difference to the time it takes to determine the blocks that need to be written as Oracle introduced the "checkpoint queue" in 8i. When a block first becomes dirty it is appended to the queue, so the database writer only has to walk the queue in order to find blocks that need to be written.

One of the threats comes from consistent read copies - if you have an excessively large buffer you may find extreme numbers of copies of the same block building up in the cache (despite the notional limit of 6 set by the _db_block_max_cr_dba parameter). Since all the copies will be covered by the same cache buffers chains latch, processes may start to hold the latch for long periods of time as they search the chain for the correct copy.

Another threat comes from dropping or truncating objects - Oracle needs to search the buffer for CLEAN blocks from the object and, prior to 10g (possibly 10.2), there was no really quick way to perform this search. 10g maintains an "object queue" for each object in the cache, and that is supposed to make this task more efficient.

In the case of the original poster - a 1GB database with 8GB of RAM - it's almost guaranteed that a fully cached database will be beneficial i.e. 1GB of db_cache_size - but keeping an eye open for long waits on the cache buffers chains latch.

Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums