The great grandson of Husnu Sensoy

July 9, 2009

_pga_max_size = 200M : Maximum size of the PGA memory for one process ?!?

Filed under: Oracle — kocakahin @ 11:08 pm
Tags: , ,

For almost two years, I know a lot of  people like to play UNSUPPORTED Oracle parameters for managing sql workarea size policy of Oracle. Although Mr Lewis has published tens of illustrations proving that it is impossible to put general arguments about those parameters, people are insisting on playing with those parameters and hoping that their proposals on the nature of those parameters are valid.

In this post I will be discussing PGA_AGGREGATE_TARGET (”PGA_AGGREGATE_TARGET specifies the target aggregate PGA memory available to all server processes attached to the instance”) and  _PGA_MAX_SIZE (”Maximum size of the PGA memory for one process) parameters from the perspective of PL/SQL development by examplifying things. At the bottomline you will understand that _PGA_MAX_SIZE is not the maximum PGA memory for one process but it is the turn point for SQL workarea content to be purged on to a temporary tablespace. Moreover although PL/SQL local memory structures are also allocated within PGA, those parameters have nothing to do with the memory allocation of PL/SQL codes. They are for SQL workarea requirements like hash join, group by, sort, and direct path load buffers.

Filling up the World’s Simplest Collection

The machine I did those tests was a 4 CPU Sun Sparc machine with 64 GB memory and running Sun Solaris. The database version was 10.2.0.4 and PGA_AGGREGATE_TARGET parameter was 24M. All UNSUPPORTED parameters had their default values. So _PGA_MAX_SIZE was 200M for that instance. So once you read the definition you think that it is not allowed for a single Oracle process to exceed 200M of allocated PGA memory (or used PGA memory if you like). Look at the following demonstration:

declare
type myarray_t is table of varchar2(32767);
myarray myarray_t := myarray_t();
i       pls_integer := 1;
begin
dbms_application_info.set_module(’PGA USAGE TEST’,'SIMPLEST COLLECTION : 0′);
loop
myarray.extend;
myarray(i) := dbms_random.string(’u', 32767);
dbms_application_info.set_module(’PGA USAGE TEST’,'SIMPLEST COLLECTION : ‘||to_char(i));
i := i + 1;
end loop;
end;
/
declare
  type myarray_t is table of varchar2(4000);
  myarray myarray_t := myarray_t();
  i       pls_integer := 1;
begin

  dbms_application_info.set_module('PGA USAGE TEST','SIMPLEST COLLECTION : 0');

  loop
    myarray.extend;
    /**
    Longest string that dbms_random.string can generate is 4000 even if you set len parameter to higher values.
    */
    myarray(i) := dbms_random.string('u', 4000);
    dbms_application_info.set_module('PGA USAGE TEST','SIMPLEST COLLECTION : '||to_char(i));
    i := i + 1;
  end loop;
end;
/

While executing this script from one  session , monitor the PGA usage from v$process view periodically by using

set linesize 500

column display_value format a5

select * from v$sql_workarea_active;

select p.PGA_USED_MEM / 1024 / 1024 pga_used,

       p.PGA_ALLOC_MEM / 1024 / 1024 pga_alloc,

       p.PGA_FREEABLE_MEM / 1024 / 1024 pga_freeable,

       s.MODULE,

       s.ACTION

  from v$process p, v$session s

 where p.ADDR = s.PADDR

   and s.MODULE = 'PGA USAGE TEST'

 order by p.PGA_ALLOC_MEM desc;

If there is no other running task on the system, you won’t see any kind of workarea allocation by the server. So all those PGA parameters have nothing to do with your execution. And if you plot the all over PGA memory allocation for our execution you will see something similar to:

pga_usage_in_plsql

As you see the PGA usage of a single process can be much larger than magic 200M when it comes to PL/SQL. Those parameters have nothing to do with PL/SQL collections’ memory usage. More dramatically if you continue to extend the collection, at some point your OS starts to swap the Oracle memory onto disk. So this means an evil developer can lead in a system crash by just doing some careless memory allocation.

One final thing to be mentioned is the ratio between PGA_ALLOCATED and PGA_USED. I have noticed that as the size of collection increases in time, Oracle starts to converge to a fix ratio (in may case it was ~2.65) for PGA_ALLOCATED/PGA_USED. It is good in the sense that Oracle keeps a constant correlation between used PGA and allocated PGA for PL/SQL collections.

correlation

 Conclusion

Sorry but Oracle doesn’t promise for anything it has not documented. Although x$ksppi.ksppdesc column describes _PGA_MAX_SIZE  parameter as the maximum PGA allocated for an Oracle process, it doesn’t say anything specific about PL/SQL memory usage. So you should ensure that your code is not using TOO MUCH MEMORY. For example, you should guarantee that you are not trying to bulk fetch a very large table at a time in your code, or you are not assuming that  the table you are fetching will not grow in time.

June 25, 2009

APEX Roadmap : APEX 4.0

Filed under: Event, Oracle — kocakahin @ 9:51 am
Tags: , , , ,

Since 2006 I haven’t been developing by using Oracle APEX. As far as I remember version was 1.5 or 1.6 at that time. In time, I heard lots of great things about APEX from many people (maybe the most important one is Tonguc). So I have decided to attend Oracle Application Express 4.0 sessions at ODTUG this year. As Oracle guys have mentioned in their presentations, I will also stress that the things written in this post is just reflecting a direction. No promise that you will find all in the production release. So, here are the list of a few things thought to be available by APEX 4.0

Easy Way to Develope : Web Sheets

Even for simple form & report based applications (acutally it is a much general problem) the major problem is that users always ask for something different from what developers put on.It seems that Oracle APEX development will be possible by the actual users of the applications in the near future. With Web Sheets, Oracle’s aim is to let user to produce his/her own applications on APEX without bothering any developers. Builder and Run Time components of APEX are being merged within Web Sheets to let the development of dirty quick applications by users themselves.

For example, instead of a marketing guy sending a report to a sales guy in an Excel sheet (including some tabular data, charting, may be some input fields, etc in it) attached to an e-mail, he can simply put the report on intranet via an application easily developed on APEX. He or others can add some attachments, tags, comments on some data. Moreover, if the producer of the application or anyone else changes any piece of data, all chages will be audited. Even more they can add some notifications for their reports so that reports can be automatically sent to their e-mail boxes.

Obviously there are some differences in developing a classical APEX application and a Web Sheet. Here are just three differences between an APEX application and a Web Sheet:

APEX Application Web Sheets
Primary Key Maintenance Trigger or Sequence Automatically Managed
Page Flow Controlled by branches Limited
Look & Feel Themes & templates Basic Control

Declarative Way of Scripting : Dynamic Actions

One of the most popular things on web technologies is to put some intelligence on client-side by using cool AJAX stuff. The major problem in here is for such database geeks like me who doesn’t know anything about writing a piece of javascript. The basic idea behind dynamic actions is to allow developer to create client side AJAX actions in a declarative fashion without writing a piece of code.

Better Charts : Integration with AnyChart 5.1

When I gave up developing APEX, the only charting option you had was SVG (Support Vector Graphics). It seems that in time Oracle put another option of charting, namely flash charts into APEX. APEX uses the flash charts developed by an Oracle Partner company AnyChart. In version 4.0 the latest version of this charting module (currently 5.1) will be embedded into APEX.

Integration with Other Applications : REST Web Services

It seems that currently APEX does support SOAP Web Service calls from the applications you have built with APEX. By APEX 4.0, Oracle will also allow you to call REST Web services. Besides the architectural differences between a SOAP web service and a REST web service, the list of a few REST web services seems to be very attractive for many applications:

  • Yahoo Map
  • Flicker
  • Google Picasa
  • Amazon Products

And in the demo, Oracle guys show that how it is easy to embed a map into your application.

Extensibility : Plug-ins

Due to the fact that it is impossible /impractical to satisfy all individual customer needs, by APEX 4.0 Oracle introduces the concept of plug-in. You will be designing your own plug-ins by using bare PL/SQL APIs and you will be able to use it as an item in your applications and hopefully you will share that item for me (or the rest of the community) to use it. I think this is one of the best features and we will be using very fancy APEX plug-ins developed by many people just like the plug-ins developed for Firefox. In the presentation one classical example of these plugins was demonstrated. That was infamous star rating plugin

star rating plugin

Finally, I am pretty sure that there will be many more in APEX 4.0 when it becomes available. So hope to return back to development some day and meet with APEX 10.0 at that time J

June 21, 2009

Before ODTUG Kaleidoscope Day 1

Filed under: Event, Oracle — kocakahin @ 3:07 pm
Tags: , , ,

odtugHi there,

After a long trip to San Jose (around 24 hours :) ), today we have ride to Monterey with my friend Anil. Monterey is a very quite, beautiful city near by the ocean. Although it is in June, Monterey was extremely cold today. We have walked on the sand at sea shore, eat something in a fish restaurant and walk around the city town.

Our hotel Montery Hyatt Regency is one of the best hotels I have ever been. Nice green golf fields, quite environment, and smiling face staff (Thanks Joe for your advices about the down town).

3 hours ago, I have woke up for a phone call (at 2 am in the morning). And my manager was on the phone asking for help on one of the systems I have recently engineered. After solving the problem in the RAC cluster, I had started to write to share my tomorrow (Sunday) program in Kaleidoscope. It seems that I will be attending to APEX stream for whole day. Especially I am curios about following sessions:

  • Keynot Session by Joel Kalman, Oracle Corp
  • Leveraging Oracle 10gXE, APEX, and SQL*Developer to Build  an MDM Solution by Shravan Kumar, APEXor
  • APEX Panel Discussion

See you in Kaleidoscope Day 1

April 12, 2009

Our Data Warehouse Podcast

Filed under: Datawarehousing, Oracle — kocakahin @ 9:15 pm
Tags: , ,

 Hi there,

The podcast we have recently performed is available. Click here…

March 31, 2009

ORION IO Calibration Cookbook

Filed under: Oracle, Uncategorized — kocakahin @ 6:21 pm
Tags: , , ,

ORION is one of the most important calibration tools of my toolbox. In any project before installing any Oracle software (clusterware, ASM or RDBMS), the first thing I do is to calibrate disks of the system. That’s because history is full storage related Oracle stories.

In this post, you will find a simple cookbook of calibrating a storage array by using ORION. I will go through a real calibration test I did three months ago.

Preparing a .lun file

In any ORION test, the first thing you should do is to prepare a LUN file with extension .lun to list your devices (with the assumption that you will be testing raw devices. ORION also let you to test file systems in which you should use synthetically created large files in place of device names) to be calibrated. Here is our lun file

[oracle@consol10g orion]$ cat mytest.lun
/dev/dm-2
/dev/dm-3
/dev/dm-4/dev/dm-5
/dev/dm-6

 

One important point is that you should ensure that the OS user you will be performing the test has the necessary grants over the devices you will be calibrating.

Small Random & Large Sequential Read Load

I always start with pure small (8K) random and then pure large (1M) sequential read load calibration first. That is simply because if these two tests fail to satisfy your performance needs there is no point in doing any other tests. You can simply call back your vendor or infrastructure team.

Here is the ORION syntax we will be using

[oracle@consol10g orion]$ ./orion_lnx     -run advanced -testname mytest -num_disks 40 -simulate raid0 –write 0                                           –type seq –matrix basic –cache_size 67108864 -verbose

 Let us discuss this parameterization. In order to control other options in detail I have set run option to be advanced. testname option should set to be the name of .lun file. num_disks is the number of disks in your storage array. Actually, you can set this parameter to any value you like it is just an input for calculating the maximum number of small IO and large IO requesters (for value less than 10 max small IO requesters= 5*num_disks and max large IO requesters = 2*num_disks).simulate parameter is always raid0 me, because I always use ASM. type option defines the type of large IOs (sequential/random). Since the test covers pure random and pure sequential IO loads, matrix option is set to be basic. cache_size is a critical parameter you should learn by get in touch with your storage admin. This is the size of your storage array cache in MB. If you set this parameter too low your outputs will be too good to be true, if you set too high your test run time will be too long. verbose is the parameter to guide ORION to print progress status on standard output.

Keep in mind that you should run ORION from the same directory where mytest.lun file resides. When the execution is over you will find three new files in your current working directory. Those are mytest_*_summary.txt, mytest_*_iops.txt, mytest_*_lat.txt, mytest_*_mbps.txt files.

Figure 1 Pure Random and Pure Sequential Loads

As you see the number of read IOPS is increasing with the increasing number of outstanding random read requesters to a certain point. This is what we expect to see from queuing theory. However, there is another restrictive parameter over that, called latency. If the service time of a single read request exceeds 10ms on the average, (some others say 20ms) then the user will start to suffer.

So keep in mind that doing ~100.000 IOPS means nothing. What is meaningful is that you can deliver ~3500 IOPS with 19.5 ms service time. In other words never use IOPS metric barely. Always cascade average service time, latency, queuing time, etc metrics.

The interpretation of sequential IO is different. In high throughput demanding systems, nobody will deal with the service time of a single IO request. The import thing is to fully utilize the whole storage infrastructure in order to deliver the highest rate of throughput possible. Therefore, “160 MB/s read throughput” statement is OK.

 

Mix Read Load

The last thing you should test is the behavior of storage array under various mix loads. Let me exemplify the importance of this test. You might see some systems running in peace whole day long but 1-2 hours night time (backup window). Alternatively, you might see some DBAs periodically kill reporting users in OLTP systems.

Those are all related with insufficient IO configurations. Large IO requests caused by backup, reporting,etc activites may result in a severe change in the service time of small IO requests. Therefore, you should have a priori knowledge in what proportion, small and large IO requests can cause a problem on your storage infrastructure. Here is the ORION syntax

[oracle@consol10g orion]$ ./orion_lnx     -run advanced -testname mytest -num_disks 40 -simulate raid0 –write 0                                           –type seq –matrix detailed –cache_size 67108864 -verbose

 Notice that the only change in here is that matrix option is set to be detailed. When matrix option is basic, ORION generates random IO at N different levels without sequential IO requesters and then it generates sequential IO at M different levels without random IO requesters. When the option equals to detailed, ORION generates all possible MxN combination of random & sequential IO genererators.

 Figure 4 Mix Read Load

To interpret Figure 4, let’s think that our storage array is capable of serving only 8K requests. Any larger requests will be chopped into 8K pieces. That means a large IO request will be corresponding to 125 small IO requests. Moreover think that the total capacity of our storage array is 2000 small IOPS. Now by simple division you can either yield 2000 small (8K) IOPS or 16 large (1M) IOPS from this storage array or somewhere between.

So when the number of total large IO requesters increase, the number of total IOPS will decrease.

Now assume that sustaining 1500 IOPS requires 10 ms, 3000 IOPS requires 20 ms service time on the average. While we are sustaining 1500 IOPS, we can either move on large requester axis and with an addition of 12 IOPS we can reach 20 ms latency, or we can move on small requester axis and with an addition of 1500 IOPS we can reach 20 ms latency (We may choose a third option somewhere between also). As a result increase in large IO results in an increase in service time also.

Conclusion

In this post, I try to show how ORION can help you in detecting your possible disk performance problems before they occur on production. Remember that on an enterprise storage infrastructure there are more than just a bunch disks. The major performance problem can be related to components like HBAs, switches, port issues, backend problems, or even IO scheduling algorithm you use.

Mathlab Codes to Create Charts

In order to generate the plots you’ve seen in this post you can use orion_chart_basic.m and orion_chart_detailed.m scripts with mathlab. When you execute them(F5), they will ask you to choose a directory. This directory should contain all ORION output files of a single run. Once you pick the directory, mathlab will do the rest.

CAUTIONS

  • For tests executed with run option set to be basic you should use orion_chart_basic.m
  • For tests executed with run parameter set to be detailed you should use orion_chart_detailed.m
  • Each directory you choose should contain one and only one set of ORION run output file.
  • All four mathlab files should be in the same working directory.

randomIOChart.m

function randomIOchart(concSmallIO, IOPS, latency)
[haxes,hline1,hline2] = plotyy(concSmallIO,IOPS,concSmallIO,latency,’plot’);
axes(haxes(1));
xlabel(’Outstanding Small IO’)
ylabel(’IOPS’);
title(’Random I/O’,'FontSize’,14)
j = 1;
[m n]=size(latency)
while latency(j) < 20
    j = j + 1;
    if n == j,
        break;
    end

end

 

text(concSmallIO(j-1),IOPS(j-1),[int2str(IOPS(j-1)),' IOPS with ',num2str(latency(j-1)),' ms latency \rightarrow' ],’HorizontalAlignment’,'right’,'FontSize’,12)

axes(haxes(2));

ylabel(’Latency(ms)’);

 

sequentialIOChart.m

function sequentialIOchart(largeIO,mbps)
plot(largeIO,mbps,’-rs’,'LineWidth’,2,…
‘MarkerEdgeColor’,'k’,…
‘MarkerFaceColor’,'g’,…
‘MarkerSize’,10)
xlabel(’Outstanding Large IO’)
ylabel(’MB/s’)
title(’Sequential I/O’,'FontSize’,14)

 

orion_chart_basic.m

%Use this file for ORION test output executed with -run basic option
%When the directory selection pop appears, pick the folder that contains
%ORION run outputs.
orion_directory = uigetdir();
 latency_file = dir(fullfile(orion_directory,’*_lat.csv’));
iops_file = dir([orion_directory,'\*_iops.csv']);
mbps_file = dir([orion_directory,'\*_mbps.csv']);
 latency = csvread(fullfile(orion_directory,latency_file.name), 1, 1)
latency = latency(1,:)
small = csvread(fullfile(orion_directory,latency_file.name), 0, 1);
small = small(1,:)

 

iops = csvread(fullfile(orion_directory,iops_file.name), 1, 1);

iops = iops(1,:);

 

subplot(2,1,1);

randomIOchart(small, iops, latency)

 

mbps = csvread(fullfile(orion_directory,mbps_file.name), 1, 1);

large = csvread(fullfile(orion_directory,mbps_file.name), 1, 0);

large = large(:,1);

subplot(2,1,2);

sequentialIOchart(large,mbps);

 

orion_chart_detailed.m

%Use this file for ORION test output executed with -run detailed option
%When the directory selection pop appears, pick the folder that contains
%ORION run outputs.
orion_directory = uigetdir();
 latency_file = dir(fullfile(orion_directory,’*_lat.csv’));
iops_file = dir([orion_directory,'\*_iops.csv']);
mbps_file = dir([orion_directory,'\*_mbps.csv']);
 latency = csvread(fullfile(orion_directory,latency_file.name), 1, 1);
small = csvread(fullfile(orion_directory,latency_file.name), 0, 1);
small = small(1,:);
large = csvread(fullfile(orion_directory,latency_file.name), 1, 0);

large = large(:,1);

 

subplot(2,2,1);surf(small,large,latency);xlabel(’Outstanding Small IO’);ylabel(’Outstanding Large IO’);zlabel(’Latency (ms)’);

 

iops = csvread(fullfile(orion_directory,iops_file.name), 1, 1);

subplot(2,2,2);surf(small,large,iops);xlabel(’Outstanding Small IO’);ylabel(’Outstanding Large IO’);zlabel(’IOPS’);

 

mbps = csvread(fullfile(orion_directory,mbps_file.name), 1, 1)

small = csvread(fullfile(orion_directory,mbps_file.name), 0, 1);

small = small(1,:)

large = csvread(fullfile(orion_directory,mbps_file.name), 1, 0);

large = large(:,1)

subplot(2,2,[3 4]);surf(small,large,mbps);xlabel(’Outstanding Small IO’);ylabel(’Outstanding Large IO’);zlabel(’MB/s’);

SQLAlchemy for Oracle ORM in Python

Filed under: Oracle — kocakahin @ 2:55 am
Tags: , , , , ,

smilingpythonHi there,

I am trying to learn Python for some daily scripting activities on Oracle databases. I hope you all familiar with ORM tools available for other programming languages. I have already found a very developer friendly ORM tool for Python called SQLAlchemy. In this post you will find a basic usage of this tool to write better Oracle-Python codes. We will be going through the answer of a simple question:

How to compute an ASM Diskgroup Read Rate?

with my special thanks to Anil Chalil…

March 27, 2009

Please Welcome the Young ACE Director

Filed under: Oracle — kocakahin @ 7:00 am

ACE DirectorHi there,

I am finally an Oracle ACE Director. Oracle has recently honored me as the first ACE Director of Turkey. Moreover it seems that I am first or second youngest ACE Director among all. It is also another pleasure for me (ACE Profile).

For a long time, I am coping with several projects and disaster recovery tasks. After finishing all, wait for my new posts.

See you

September 30, 2008

Oracle 10g DBA: Adding Time Information into Tablespace Names

Filed under: Oracle — kocakahin @ 4:35 am

In VLDB databases, there is a common willing in using a tablespace naming convention that includes seasonal information of data within tablespace, such as CHURN_2008M01 or SALE_2008W50. This has various benefits in terms of ILM (Information Life Cycle) management. By just looking the name of a tablespace, the DBA can have a pretty good idea about the tablespace and segments within that tablespace. Nevertheless, prior to 10g this convention can cause significant degeneration in system catalog performance if data windowing is used. In other words, if you periodically need to drop old tablespaces and add new ones, Oracle catalog starts to blow up. In this paper, you will find a tricky way of solving this problem by Oracle 10g.

Read rest of the paper…

This post consists of my article published in IOUG “Oracle Technology Best Practices” booklet delivered in Oracle Open World 2008.

September 24, 2008

My Open World Presentation Experience

Filed under: Oracle — kocakahin @ 11:04 pm

Hi there,

As I’ve promised, I publish my presentation I held on Tuesday in Oracle Open World. It was a really challanging experience  for me to perform a presentation in such a great event. Moreover one of the Oracle experts, Julian Dyke, I really like to read attented to my presentation. And I am very proud of hearing his positive feedbacks about my presentation. Thanks a lot Julian. Hope to see you in Birmingham…

I also want to thank to Reiner Zimmermann from Oracle, all my collegues and managers in Turkcell, and Hasan Tonguc Yilmaz for their supports and ideas in preparing this presentation.

Growing Data Warehouse to 50 TB and beyond…

September 17, 2008

Oracle 11g SQL: Named & Mixed Notation for PL/SQL in SQL Statements

Filed under: Oracle — kocakahin @ 9:02 pm

 In programming language theory, positional notation refers to matching the order of formal parameters and actual parameters.  Whereas named notation refers to matching the formal parameters and actual parameters explicitly usually (not necessarily) by some operator (in PL/SQL this operator is =>). Finally mixed notation refers using both together as a single notation.

Although there was no restriction on using any of those notations within PL/SQL blocks, prior to 11g named & mixed notations for PL/SQL subroutines were not allowed in SQL statements (Code Piece 1 and Code Piece 2). This is one of the most restrictive issues about SQL for developers. Luckily 11g solves that issue and now it is allowed to use named and mixed notations also in SQL statements.

Read rest of the paper…

Next Page »

Blog at WordPress.com.