Ask the Expert

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?

    Requires Free Membership to View

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


This was first published in July 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: