Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

When are records released from SGA?

Once a record is created in PL/SQL, when is that record released from SGA? In other words, must the programmer explicitly release that record from memory or will Oracle release it once the program has finished running?

To answer your question, I'm going to assume that you are asking about PL/SQL record variables...not records inserted into tables.

Here's the general rule of thumb regarding SGA (and PGA) memory usage.

  • When a package is first instantiated, the package p-code is read from disk and put into the shared pool in the SGA. This can be "aged out" if space is needed in the SGA and thus may require reloading.
  • Packaged variables (such as PL/SQL record variables) and cursors are kept in session memory in the PGA. These items will persist for the life of the session.
So, record variables that are populated/used in your application code are maintained in the PGA and thus kept until the user's session ends...not just until the program has finished running. An option a programmer has is to create the package using PRAGMA SERIALLY_REUSABLE.

Packages marked with the PRAGMA SERIALLY_REUSABLE will be kept in the SGA rather than the PGA and will last only for each database call.

For More Information

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.