05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4 ■ MEMORY STRUCTURES 127<br />

exit when l_status = 0;<br />

for x in ( select * from big_table order by 1, 2, 3, 4 )<br />

loop<br />

null;<br />

end loop;<br />

end loop;<br />

end;<br />

/<br />

exit<br />

The script to stop these processes from running is as follows:<br />

begin<br />

dbms_alert.signal( 'WAITING', '' );<br />

commit;<br />

end;<br />

To observe the differing amounts of RAM allocated to the session I was measuring, I initially<br />

ran the SELECT in isolation—as the only session. I captured the same six statistics <strong>and</strong><br />

saved them into another table, along with the count of active sessions. Then I added 25 sessions<br />

to the system (i.e., I ran the preceding benchmark script with the loop in 25 new sessions). I<br />

waited a short period of time—one minute for the system to adjust to this new load—<strong>and</strong> then<br />

I created a new session, captured the statistics for it with reset_stat.sql, ran the query that<br />

would sort, <strong>and</strong> then ran watch_stat.sql to capture the differences. I did this repeatedly, for<br />

up to 500 concurrent users.<br />

It should be noted that I asked the database instance to do an impossible thing here. As<br />

noted previously, based on the first time we ran watch_stat.sql, each connection to <strong>Oracle</strong>,<br />

before even doing a single sort, consumed almost .5MB of RAM. At 500 users, we would be<br />

very close to the PGA_AGGREGATE_TARGET setting just by having them all logged in, let alone<br />

actually doing any work! This drives home the point that the PGA_AGGREGATE_TARGET is just<br />

that: a target, not a directive. We can <strong>and</strong> will exceed this value for various reasons.<br />

Table 4-1 summarizes my findings using approximately 25 user increments.<br />

Table 4-1. PGA Memory Allocation Behavior with Increasing Numbers of Active Sessions, with<br />

PGA_AGGREGATE_TARGET Set to 256MB<br />

Active PGA Used by PGA in Use Writes to Temp by Reads from Temp<br />

Sessions Single Session by System Single Session by Single Session<br />

1 7.5 2 0 0<br />

27 7.5 189 0 0<br />

51 4.0 330 728 728<br />

76 4.0 341 728 728<br />

101 3.2 266 728 728<br />

126 1.5 214 728 728<br />

151 1.7 226 728 728<br />

177 1.4 213 728 728<br />

Continued

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!