Wednesday, December 22, 2010

Fake Id's In Niagara Falls

Comparison of Methods and Types of joins in Oracle

To build the execution plan the optimizer should perform the following basic actions:

  1. determine the order of evaluation of the tables.
  2. determine the method join.
  3. determine the types of access (access path, eg full scan, rowid, index range, etc).
  4. determine the order of filtering.

The first 3 are the tree structure that supports the implementation plan. The 4th defines the data flow "Flows" through the tree. This time I'll just concentrate on point 2, leaving the other for future notes.

The joins are always made between two sets of data, if the sentences had more than two tables are determined by the first two tables both join and the result is joinea the table below, this result is joinea with the following table and so on .
join
The most common methods are:

  • NESTED LOOP JOIN MERGE JOIN SORT JOIN HASH
  • Cartesian join

Description NESTED LOOP JOIN

The two sets of data processed for nested loop (NL) are called outer loop and inner loop. The outer loop is executed once and the inner loop once for each record returned by the outer loop. The main features of NL are:

  • are the best choice when you need to get the front row as soon as possible, so you do not need to process all the data to start returning results. This is very performing, for example, front-end applications that use pagination. Leverages
  • filters and joins conditions using available indexes.
  • can be used with any type of joins.

Description HASH JOIN

The two sets of data processed for hash join (HJ) are build input and probe input. With the build input is built in memory (or temporary tablespace if there is insufficient physical memory available) a hash table. Once built the build input is used to start processing each record in the input probe the hash table so as to compare whether or not it meets the join condition. The main characteristics of HJ are

  • The hash table is usually built using the smaller dataset.
  • Not all types of joins can be used, such as theta joins and cross joins are not supported.
  • That is starting to return rows from the hash table must be created and processed.
  • HJ
  • can not implement joins using indexes conditions.

MERGE JOIN SORT Description

The two sets of data processed by the merge join (MJ) are read and sorted according to the columns referenced in the join condition. Once the two set are sorted are mixed (merge). The ordering is done in memory as long as physical memory is sufficient, but reaches the memory (pga) temporary space should be used as a support which, as expected, slow down operations. The main characteristics of MJ are

  • Both data set must be ordered before merge
  • The first row of the result set is returned recently when the merge starts.
  • All types of joins are supported.

Types of Joins

There are two possible syntaxes for use with joins: SQL-


ANSI-86 SQL-ANSI-92

The first is the general use, and is the most common, the second is newer and is standard for other database engines, is more common for new generations of developers and DBAs, or for those who come to use sql server. It is also clearer because it separates the filters of joins, which is easier to read and interpret. Now I will give a brief overview of the types of joins with examples in the two notations:


Join

Cross also called Cartesian product. It is generally used when the joins are not specified for some tables. I've also seen some private plans where is the best option, although very rare
 
select emp.ename, dept.dname
from emp, dept

select emp.ename, dept.dname
from emp CROSS JOIN dept


Theta Join

also called inner join, and returns only the rows that satisfy a join condition
 
select emp.enam, salgrade.grade
from emp, salgrade WHERE
emp.sal entre salgrade.hisal

salgrade.local and select emp.ename, salgrade.grade
from emp INNER JOIN on emp.sal entre salgrade salgrade.losal and salgrade.hisal



Equi Join

also called natural join is a special case of theta join where
operators are used only for equality join conditions
 
select emp.ename, dept.dname
from emp, dept WHERE
emp.deptno =
dept.deptno
select emp.ename, dept.dname
from emp NATURAL JOIN dept on emp.deptno = dept.deptno


Self
Join
are a special case of theta join where the joined table is the same.
 
select emp.ename, mgr.ename
from emp, emp WHERE mgr
emp.mgr = mgr.empno


select emp.ename, mgr.ename
JOIN emp mgr from emp on emp.mgr = mgr.
empno


Outer Join

The outer join extends the result set of theta joins. With this kind of join the ranks of all the tables involved are returned if no match with the columns join the other table, returning NULL in the columns of the records that matches a table. Oracle uses its own syntax, but it is advisable to use the ANSI-92 syntax as it is portable to other database engines.

For example, to see the number of employees by department, considering also the departments that have no employees:
 
dept.dname select count (emp.ename)
from emp, dept WHERE
emp.deptno dept.deptno = (+)
group by dept.dname

dept.dname select count (emp.ename)
dept from emp LEFT OUTER JOIN on (dept.deptno = emp.deptno) group by dept.dname


With the new syntax also you can use RIGHT OUTER JOIN and FULL OUTER JOIN.

From Oracle 10g you can use a new type of join (or subtype) called partitioned outer join. This type of join a priori would seem to be related to partitioned tables but not in this case, the concept of partitioning is that the data are divided into subset during the execution
 
dept.dname select count (emp.empno)
dept from emp LEFT JOIN PARTITION BY (emp.job) ON emp.deptno = dept.deptno
group by dept.dname


Semi Join

This type of join between two tables returns only rows of a column in the tables which exist in the other join table.

For example, to see that employees are bonus:
 
scott.emp select * from emp

WHERE exists (select null from bon
scott.bonus WHERE emp.EMPNO = bon.ename)

select * from scott
.
emp emp WHERE empno in (select empno from scott.bonus bon)



Join Anti

This type of join between two tables returns only rows of tables whose columns are NOT join in the other table

For example, to consult employees who do not have bonus:
 
scott.emp select * from emp

where not exists (select null from bon
scott.bonus WHERE emp.EMPNO = bon.ename)

select *

scott.emp from emp WHERE empno NOT IN (select empno from scott.bonus bon)


Once reviewed the types of methods joins joins we return and see some examples as plans are put together according to each method:

As always I will create the environment in order to try and if anyone wants to test it in their own environment can:
 
- I table t1 create table T1

as select rownum
c1,
trunc (dbms_random.value (1100)) c2,
dbms_random.string ('a', 100)
c3 from dual connect by rownum
<= 1000000 -- Creo tabla T2 create table t2 as select rownum c1, trunc(dbms_random.value(1,100000)) c2, dbms_random.string('a',100) c3 from dual connect by rownum <= 2000000 -- Creo un indice para la tabla T2 create index t2_idx on t2(c2) -- Recolecto estadisticas para los segmentos creados: begin dbms_stats.gather_table_stats(ownname => user, tabname => 'T1', cascade => true);
dbms_stats.gather_table_stats (ownname => user, tabname => 'T2', cascade => true);
end;


Now I will show each join method, obviously I'm going to tamper with hints to make it simple:

be forced to use NESTED LOOP JOIN:
 
select / * + Leading (t1) use_nl (t2) index (t2) * / count (1)
from t1, t2 WHERE t1
. c2 = t2.c2
and t1.c3> 'zzz'

Plan hash value: 3705558160

-------------------------- -------------------------------------------------- -
1 para que se use MERGE JOIN:



select /*+ ordered use_merge(t2) */ count(1)
from t1, t2
where t1.c2 = t2.c2 and t1.c3 > 'zzz'
Plan hash value: 1164406001

------------------------------------------------------------------------------------------
Information (identified by operation id):
---------------------------------------------------

4 - filter("T1"."C3">'zzz')
5 - access("T1"."C2"="T2"."C2")
filter("T1"."C2"="T2"."C2")


 Forzamos para que se use HASH JOIN: 



select /*+ leading(t1) use_hash(t2) */ t1.*
from t1, t2
where t1.c2 = t2.c2
and t1.c3 > 'zzz'


Plan hash value: 442409572

---------------------------------------------------------------------------------
(%CPU)
Predicate Information (IDENTIFIED BY operation id): ---------------------------------------


------------ 2 - access ("T1". "C2" = "T2". "C2")
3 - filter ("T1". "C3"> 'zzz' )

Comparing the 3 plans for each method is used only with NL index range rather than using a full scan of the index. NL times are best estimates the value of plan. Running each of the 3 queries can be seen that this estimate is in line with reality and that NL is the fastest. This is because both HJ and MJ can not use the index to find matches over the table T2 based on the values \u200b\u200breturned by the table T1. With NL is used to access that information more promptly, via the index. The lower the selectivity (or stronger) the NL method will have greater advantage over the other two.




Wednesday, December 15, 2010

Bejeweler Pro Example

When a query uses an index, but not the best possible rate


Many times I asked that a query does not respond in a timely manner when the execution plan shows that you are using an index. The answer in some cases is very simple and because the index is not as selective as possible, no filters that could filter everything. To say that a query uses an access plan for an index is not sufficient to ensure that you have found the most efficient way. To show a bit of that I'm talking about putting together a case, but somewhat trivial therefore less instructive, so that they understand the idea.
I will create a T-chart with 3 columns. COL1 column will have 1000 distinct values \u200b\u200band column COL2 will have 10 possible values. Also add filler column COL3


 

create table t as



select mod (rownum, 1000) col1,


mod (rownum, 100000) col2,
dbms_random.string ('a', 50)
col3 from dual connect by rownum





Once you create the table I create an index for COL1 and harvest statistics for table and index:

t_idx create index on t (col1) begin


dbms_stats.gather_table_stats (ownname => user, tabname => 'T', cascade => true);
end;



I run the following query and extract the plan using DBMS_XPLAN.DISPLAY_CURSOR so that the plan be more detailed (in a future I will use the same method to show how to see how "confused" the optimizer when there are no adequate statistics):
select / * + * gather_plan_statistics / * from t where col1 = 9

and

col2 = 9 select * from table (dbms_xplan.display_cursor (null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT

----------------------------------------------------------------------------------------------------
 SQL_ID  25p2md7bszhj6, child number 0 
------------------------------------- select /*+ gather_plan_statistics */ * from t where col1 = 9 and col2
= 9

Plan hash value: 1020776977
-----------------------------------------------------------------------------------------------
filtering 10, as shown in step 1 (A-Rows)

(Note: A-Rows is the number of actual rows and E-Rows is the number of rows estimated)
<= 1000000
Now I will delete the index and T_IDX I will create another with the same name but indexed by COL1 and COL2. Let the new plan:


drop index create index t_idx
t_idx on t (col1, col2)
 
select / * + gather_plan_statistics 2 * / * from t where col1 = 9

and col2 = 9 select

* from table (dbms_xplan.display_cursor (null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
--------------------------- -------------------------------------------------- -----------------------
SQL_ID 25p2md7bszhj6, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from t where col1 = 9 and col2
= 9
 Plan hash value: 1020776977 

-----------------------------------------------------------------------------------------------
10 fewer resources and therefore less processing time to obtain the same output.

The moral is that you should never settle for just verify that the decision reached by an index and in-depth analysis on the current checking indexing is the best index possible or if you can find some other combination more efficient.




Thursday, December 9, 2010

Chines Banges Long Hair

ADVERTISING HAPPY YEAR 2011 , IS THAT COMMUNICATION

Monday, December 6, 2010

Dungarees That Meryl Streep Wore In Mamma Mia

Recently Read Books


3 .-
  • Title :.................... .. Positioning: The concept that has revolutionized communication advertising and marketing.
  • Editorial :................. McGRAW-HILL BOOKS DE MEXICO, SA de CV.
  • Place :..................... Mexico.
  • Year :........................ June 1985.
  • :...... No. of Pages 263.
  • :.................. Authors Al Ries and Jack Trout.
Guatemala December 6, 2010 ______________________________________




2 .-
Title :......................
  • Marketing, Internet and Enterprise. Editorial
  • :................. sponsored by the Community of Madrid.
  • Place :..................... Madrid.
  • Year :........................ May 7, 2007.
  • :...... No. of Pages 148. Authors
  • :.................. Mobile Marketing Association, National Association of Internet, ISNA, Dune netwoks, Galinus, INFONA E-consultants, Interaktir Oline Media Netfilia Interactive, Comunidad de Madrid, Madrid Digital Community. _____________________________________




1 .-

  • Title :......................... Relations Public. Editorial
  • :.................... Prise Among Moderne D'Edition. Place
  • :........................ Paris.
  • :........................... Year 1969.
  • :......... No. of Pages 339


Friday, December 3, 2010

Should Men Wear One Peice Swimsuits



This idea was requested from Argentina, is ta is an innovative new company formed by four students, who study the cart's degree in marketing, I hope to see you helped. These are just sketches, not the final art



How Long Does It Take For Temezan To W

LOGO FOR CONSULTANT MAKING A GOOD NAME FOR MY COMPANY. CHRISTMAS TO SHARE

Good day / evenings for all, as you know a person without name is nothing, therefore it can name a company is very important.

Today and seen many acronyms (the first letter of one, two or more names) as name, I think from the beginning I started to analyze the issue of names, did not seem very reasonable / logical for a name, because what is being sought identified by someone else, but I recognize that there are good names that are very attractive since one thinks for first time.

This comment is because many, many names and seen are the same but with different meanings, for example, a group of football players, puts Name your team and CC just because the two founders of the team are called Carlos, the name sounds great but what would happen to a courier company is also called CC, C Charles and the other C by mail. Other examples: EPA (Pleasures and Art Space), EPA (Labour Force Survey) PPS (Purchasing Power Standard).

TEDAS account that you have to think / invest time / discussing among other things, is not just grab one or two letters of your name / service, many large companies have taken a couple of years to perfect his name.

I'll set an example, to start this blog, although I as two to three months looking for create and imagine the name, despite having the basic knowledge, I made the mistake of putting this name:

As you can tell, the great mistakes is as clear as water, "name" was so long, not is that I was thinking, maybe explain the content of the blog, that if bleating but is very long and I think that would go on mission / vision / description, etc.. here are many problems to mention this name, but leave as unique and important problem, a person not easily remember the name, being very extensive.

Following this setback, and then reasonably arrive the name of IMG ADVERTISING , and logo: IMG PUBLICIDAD
To me, this was the end, but as that been feeding me , Web and other books, I follow the road to explore new theories to improve the blog name, but said the name IMG ADVERTISING , what will the problem this?, from the search point in google, there are many similar names, this is a big problem, pretend you are in a large conference room of an advertising agency and call IMG ADVERTISING
and in that chair, raise your hand now 7 representatives of agencies called IMG ADVERTISING , you have ever happened in your school? "That big problem" for the person who wants to talk to the agency called IMG ADVERTISING. WHAT OF ALL IS IT?
This is an example of the main problem and seen.


And to create a name of a product / service or product / service, Let us be careful in creating a name, you can fall into the error of the line extension and this would cause the name uniquely positioned the company lost.

and analysis in this process if you can realize we have simplified, and this process simplification is very important that we bear in mind as the shorter but stays in the mind of the user / consumer.

The contents of this publication , also will can serve to create a good slogan.

This publication it is part of the experience and lived in the building of this blog, and as I said I eat other means against a good name for my blog.

have doubts to make a name for your business, check or leave a comment.


Gameshark Elixir Ruby



Wednesday, November 24, 2010

Biology Lab Manual A Answers

How to perform update / delete mass effectively


In this note I will show an effective method to modify or eliminate a large number of rows on a large table. In general, the voluminous tables are partitioned for scalability naturally. Partitioning mainly provides 3 types of benefits: 1) improves performance, 2) facilitates the management and maintenance and 3) increasing the availability of data. Resolve a query using as underlying table can be partitioned in the same way to solve a problem dividing it into parts. The familiar premise: divide and conquer is the main objective behind the partition.

Since the introduction of the feature of partitioning (Oracle 8) has greatly expanded the set of possible operations on tables and indexes to support and manage the tables / indices partitioned. With each new release options were added, and partitioning methods for handling operations segments. The various features introduced in each release are:





Oracle 8 (1997)




Partition Pruning (*)

Range Partitioning (includes operations ADD, DROP, RENAME, TRUNCATE, MODIFY, MOVE, SPLIT and EXCHANGE)




Oracle 8i ( 1999)



 
Hash Partitioning Composite Partitioning


: range / hash


Added

MERGE operation




Oracle 9i R2 (2002)






List Partitioning Partitioning Composite: Range / List


Clause UPDATE GLOBAL INDEXES








Oracle 10g R1 (2004)






Oracle 10g R2 (2005)

It increased the limit of partitions / subpartitions 65k to 4M
    Oracle 11g R1 (2007)
composite partitioning: range-range, list-range, list-list and list-hash.
 
 Added partitioning interval, reference and system. 
Oracle 11g R2 (2009)
    virtual and primary key columns for partitioned tables referenced. Indices

  • system partitioned by list-partitioned tables.

  • As you can see, almost every new release there was any new functionality added. However, in my opinion, the main feature has existed since the first release with partitioning (1997). I mean the partition pruning and partition pruning, which allows the optimizer (CBO always talking about) choice in automatic, accurate and transparent partition or partitions where the required data. This allows you to segment the data and process only that interest us, without adding any additional intelligence in the application code.
With respect to operations, the vast majority are from Oracle 8, only be added after the MERGE. An operation is very interensante EXCHANGE, with which you can share a table with a partition unpartitioned. It is precisely this operation that I use to propose an alternative fast to change or delete many rows of partitioned tables. Then somo usually do, I will show the steps in detail and compare the times and use of resources:
I will create a table T partitioned 3 partitions list create table t (c1 int, c2 varchar2 (10),
date c3, c4
    char (1))
  • partition by list (c4)
  • (
  • t_a partition values \u200b\u200b('A'), partition
    T_B values \u200b\u200b('B'), partition
  • T_C values \u200b\u200b('C')
  • )
 
 I'm going to insert rows 10M arbitrarily distributed on the partitions:   
insert into t select rownum, dbms_random.string ('a', 10), sysdate-dbms_random
. value (-100.100),
chr (trunc (dbms_random.value (65.68)))
from dual connect by rownum

5M Insert rows on the partition on which I will work to have more rows :

insert into t select rownum +10000000,
    dbms_random.string ('a', 10), sysdate-dbms_random.value
  • (-100.100),
  • 'A' from dual connect by rownum


After all values \u200b\u200bare loaded confirm (commit) and then collect statistics.
Consider the plan for a query that counts rows on partition 1 (t_a):
Explain plan for select count (1)
from t WHERE c2> 'R' and c4 = 'A'; select * from table (dbms_xplan.display) ------------------------------------

PLAN_TABLE_OUTPUT
    -------------------------------------------------- -------------
  • Plan hash value: 2901716037
  • -----------------------------------------------------------------------------------------------
  • ACCESS FULL from t
WHERE c4 = 'A';

COUNT (1) ----------

8333946



At this point, we already have a partition with more than 8.3M of rows which we will modify 5.6M, which is more than 67%.
 First I'll test a regular update on the table T and then make the comparison with the same change but using another approach more efficient. 

 


September update
t c3 = c3 +1
WHERE c4 = 'A'
and c2> 'R'

5610297 rows updated. After

: 00:04:45.37

 
 
The amendment took 4 ' 45 ". We think that the database must maintain consistency to ensure consistent read (using the UNDO) and persist the changes to be able to recover if a failure event occurs during the modification (REDO). These mechanisms cause the times increase and generate additional information.

review how much UNDO and REDO space is needed to perform the update:



<= 10000000;

select 'REDO_SIZE'
round (ms.value/1024/1024) value from v $
MYSTAT ms, v $ statname
WHERE sn = sn.STATISTIC ms.STATISTIC # #
 and sn.NAME = 'redo size' 
 
union all SELECT 'UNDO_SIZE'
t.used_ublk * 8 / 1024 value
FROM v $ transaction t, v $ session s WHERE
t.addr = s.taddr
AND s.audsid = userenv ('sessionid')
<= 5000000;

REDO_SIZE


2489 Mb 885 Mb
 UNDO_SIZE 
 



5.3m is needed to modify 2489Mb 885Mb redo and undo!. In the example, the table has no indices. If you have indexes and the modified column is part of the indexing columns generate more redo and undo, and also the sentence would have to update the indexes for each row modified which will cause the update takes a while longer. If it were a bulk processing instead of a delete update will generate more undo (the delete is dml operation that generates more undo) and will be balanced to keep the indices, which means more processing time.


there a simpler way to perform the update operation using partitioning star: EXCHANGE. Before using the exchange we need to create an auxiliary table (T_A) and to speed up the table as NOLOGGING set up and inserted directly using the APPEND hint.



create table t_a_aux
NOLOGGING as select / * + APPEND * /
c1, c2
,
case when (c2> 'R') then c3 else c3 end
+1 c3, c4

from t WHERE
c4 = 'A'

Elapsed: 00:00:22.04

 
 Only needed 22 "to insert the rows in the auxiliary table. With DECODE or CASE function to make a change to simulate the update. Now only remains to make the exchange between the auxiliary and the partition table with the operation t_a EXCHANGE: 






ALTER TABLE t EXCHANGE PARTITION WITH t_a
t_a_aux table;

After: 00:00:11.46

 
 The exchange took place almost 12. " Adding the auxiliary table creation and exchange, all took only 44 "!!!, ie more than 6 times faster than the traditional update. 
Running the query space for the redo and undo generated is obtained:


REDO_SIZE 1 Mb


UNDO_SIZE 0 Mb

Virtually no allocation for undo / redo. Therefore, for certain cases it is very useful to use this method to update since the processing times are significantly reduced and also the requirements of undo and redo are minimized almost completely.


 
 To remove (delete) en masse, creating the auxiliary table should only be filled with rows that do not fade. If you need to delete many rows from a non-partitioned table can use the same approach, ie replacing delete an insert into a new table, recreate the indexes and rename. 







Monday, November 22, 2010

Buy Flamin Hot Cheetos In London

CATHEDRAL OF GUATEMALA. Source

Catedral

The Cathedral is located in the heart of the historic center east of the Plaza de la Constitution, previously known as Plaza Mayor. To the north is the Palacio Nacional of Culture, built in 1943 during the government of Jorge Ubico, toward the south, Trade Portal, built in 1924. The cathedral complex includes three buildings: the Cathedral, the center, the Archbishop's Palace to the north and the old Infant School to the south. The facade of the three buildings is oriented towards the west. There is, however, a fourth building that completes the entire block, this is the rectory or parish house, the first building completed and occupied in this complex. Of the four buildings, the larger is the Cathedral, followed by the Archbishop's Palace. All are one unit and are made in the same style, becoming the only buildings block or block Historical Center which remains unchanged for almost 200 years.


Sunday, November 21, 2010

Very Old Goodnites Commercial]




Wednesday, November 17, 2010

Order Bulk Dietz & Watson Landjaeger Sausages

Reports Metrics Load and Response Times Database (10g +)

From 10g added dynamic views and historical information to understand better and faster activity database. Although Statspack and AWR reports have the information, they are based on snapshots as a reference for analyzing a range. Intervals are usually 1 hour (automatic and default in 10g +) and often have to wait for the next snapshot to get an idea of \u200b\u200bthe current activity.
With the new dynamic views can know almost in real time which is the core activity referring to the following dynamic view:
V $ SYSMETRIC
: Metrics more recent and less recent
last minute (one sample every 15 ").
V $ SYSMETRIC_HISTORY
: Last time all samples (choose one sample per 
 minute) . 
$ SYSMETRIC_SUMMARY
 
V: Summary of the activity of the last hour (maximum, minimum, average and standard deviation
).


stories and views remain part of the information of the dynamic view of the last hour
(mmon process is responsible for copy some of the most important information of the view V $ a disc) and externalize result with the following views:


DBA_HIST_SYSMETRIC_HISTORY


DBA_HIST_SYSMETRIC_SUMMARY

With this information available gives a very detailed idea of \u200b\u200bthe activity and the load profile. Here is a query that uses the view summarized and returns among others, the same data found in the reports Statspack / AWR in the "Load Profile" in the column I tabbed a second:
select metric_name, case (metric_id)
Then when to round 2016 (minval/1024/1024, 2) When 2058
Then round (minval/1024/1024, 2)
else round (minval, 2) end Min,
case (metric_id) 2016
Then when to round (maxval / 1024/1024, 2)
when 2058 then round(maxval/1024/1024,2)
else round(maxval,2) end Max,
case (metric_id)
when 2016 then round(average/1024/1024,2)
when 2058 then round(average/1024/1024,2)
else round(average,2) end Avg,
   case (metric_id) 
   when 2016 then round(standard_deviation/1024/1024,2) 
when 2058 then round(standard_deviation/1024/1024,2)
else round(standard_deviation,2) end STDDEV,
case (metric_id)
when 2016 then 'Mbytes Per Second'
when 2058 then 'Mbytes Per Second'
else metric_unit end metric_unit
from v$sysmetric_summary
where metric_id in (2003,2026.2004,2006,2016,2018,2030,
2044,2046,2058,2071,2075,2081,2123)
order by metric_id

METRIC_NAME MIN MAX AVG STDDEV METRIC_UNIT
---------------------------------------------------------------- ---------- ---------- ---------- ---------- ----------------------------------------------------------------
User Transaction Per Sec 0 28.75 24.4 1.64 Transactions Per Second
 Physical Writes Per Sec                                                   0      29.63      21.91       2.25 Writes Per Second 
 Redo Generated Per Sec                                                     0        .06        .05          0 Mbytes Per Second 
 Logons Per Sec                                                            0       1.18        .93        .08 Logons Per Second 
Logical Reads Per Sec 0 1015.72 592.05 75.19 Reads Per Second
Total Parse Count Per Sec 0 52.75 28.29 4.33 Parses Per Second
Hard Parse Count Per Sec 0 7.24 1.29 .88 Parses Per Second
Network Traffic Volume Per Sec 0 .03 .02 0 Mbytes Per Second
DB Block Changes Per Sec 0 339.75 287.39 19.15 Blocks Per Second CPU Usage Per Sec 0 11.27 9.88 51 Second centiseconds Per User Rollback UndoRec Applied Per Sec 0 3 03 07 Records Per Second
Database Time Per Sec 0 72.48 26.67 08.01 Per Second
centiseconds
previous data are available per transaction if you need it.

Now I will show how to obtain the metric based on percentiles, with ratios and percentages of the last two samples the last minute. The most newest of at most 15 seconds and the oldest is at most 60 seconds.
   
select metric_name, round (value, 2) value, metric_unit
from v $ SYSMETRIC
WHERE metric_name like '% \\%%' escape '\\'
or metric_name like '% Percent%' or metric_name like
'% Ratio%'
 
 
METRIC_NAME METRIC_UNIT
VALUE ------------------------------------- --------------------------- ---------- ------------- -------------------------------------------------- - Buffer Cache Hit Ratio
95.75% (their - PhyRead) / Achievements
Memory Sorts Ratio 100 % MemSort/(MemSort + DiskSort)
Redo Allocation Hit Ratio 100 % (#Redo - RedoSpaceReq)/#Redo
 User Commits Percentage                                                 100 % (UserCommit/TotalUserTxn) 
 User Rollbacks Percentage                                                 0 % (UserRollback/TotalUserTxn) 
Cursor Cache Hit Ratio 232.71 % CursorCacheHit/SoftParse
Execute Without Parse Ratio 63.74 % (ExecWOParse/TotalExec)
Soft Parse Ratio 96.05 % SoftParses/TotalParses PX downgraded 1 to 25% Per Sec 0 PX Operations Per Second
PX downgraded 25 to 50% Per Sec 0 PX Operations Per Second
PX downgraded 50 to 75% Per Sec 0 PX Operations Per Second
PX downgraded 75 to 99% Per Sec 0 PX Operations Per Second
User Limit % 0 % Sessions/License_Limit Database Wait Time Ratio 42.12 % Wait/DB_Time Database CPU Time Ratio 57.88 % Cpu/DB_Time
Row Cache Hit Ratio 99.75 % Hits/Gets
Row Cache Miss Ratio .25 % Misses/Gets Library Cache Hit Ratio 98.1 % Hits/Pins Library Cache Miss Ratio 1.9 % Misses/Gets
Shared Pool Free % 91.27 % Free/Total
PGA Cache Hit % 99.89 % Bytes/TotalBytes Process Limit % 24.7 % Processes/Limit Session Limit % 16.86 % Sessions/Limit
Streams Pool Usage Percentage 0 % Memory allocated / Size of Streams pool
Buffer Cache Hit Ratio 96.18 % (LogRead - PhyRead)/LogRead
Memory Sorts Ratio 100 % MemSort/(MemSort + DiskSort)
Execute Without Parse Ratio 64.59 % (ExecWOParse/TotalExec)
Soft Parse Ratio 95.72 % SoftParses/TotalParses
Host CPU Utilization (%) 4.39% Busy / (Idle + Busy)
Database CPU Time Ratio 15.8% Cpu / DB_Time Library Cache Hit Ratio 97.64% Hits / Pins Shared Pool Free% 91.28% Free / Total

Another query that I use is more simple and I just returned the overall response time and response time per transaction, both in seconds, so you can quickly analyze and detect if something is happening with the base. I have a reasonable idea of \u200b\u200bthe times for each base and if I see something that triggers me realize looking at only those two values. Below is the query I show how I use and output it.

select end_time,
 round (max (decode (metric_id, 2106, value/100, null)), 4) "SQLRTime" 
round (max (decode (metric_id, 2109, value/100, null)), 4 ) "IMRT / Trx" from v $ sysmetric_history

WHERE metric_id in (2106.2109)
and end_time> sysdate-10/24/60

group by order by end_time end_time desc



END_TIME SQLRTime IMRT / Trx
18/11/2010 12:15:34 PM 0.0013 0.0172 0.0063
18/11/2010 12:14:33 pm 18/11/2010 12:13:33 pm
0.0843 0.1101 0.0087
18/11/2010 12:12:33 pm
0.1147 0.0039 0.009 0.1214 18/11/2010 12:11:34 pm 11/18/2010 12:10:34 pm

11/18/2010 12:09 0.0062 0.1145 : 34 pm
0.1102 0.0079 0.0081 0.1167 11/18/2010 12:08:34 pm 11/18/2010 12:07:34 pm

0.1112 0.0085 0.0078 0.1141 11/18/2010 12:06:34 pm



If you would like to see more ancient history or you are building a report summarizing historical and / or grouped by hour, day, week or month can use a historical view (DBA_HIST_xxx).

Poultice For Skin Infections

Patching 11.2.0.2 (not so patch)

Last week I had to apply the patch 11.2.0.2 on a development team. When I entered and searched metalink the patch applied to my OS (Solaris SPARC) I was struck by the size of the patch. The last patches installed memory that will not weigh much more than 1Gb. 11.2.0.2 patch on the platform weighs 5.1Gb needed!, And AIX over 6Gb. Recently when I read the documentation I understood why. The issue is that Oracle changed the policy of patching from 11.2.0.2. Now there are more incremental, but also total and contain all the bundle, ie server, client, gateway, grid, etc.

9i remember that everything came together, if a customer wanted to install only need to download 3 files that contained everything, which was cumbersome. Facilities in their independence 10g client, server, grid, etc. Now it seems that you have to download everything again and then choose to install what we need.
 is mandatory to use a separate home for the installation, the total can not be patched on the current home. In my case this new requirement does not bother me because I always consider as a good practice to install patches on a copy in a new home, to minimize risks if the patch fails partway through the installation and requires backtracking support binaries above. If you are very short of space, is a bit complicated to create a separate home so in that case you must download the bases, support binaries, remove them and install the new home. 
Installation on Solaris SPARC had no setbacks. I had to upgrader an Oracle 11g R1 (11.1.0.7) and Oracle 11g R2 (11.2.0.1). Both updates were made perfectly and without any mishap.


Tuesday, November 16, 2010

Laminating Cost At Staples

FACEBOOK Email

recently, I wondered if Facebook, you could send files as email, and today 16 November 2010. a story is to spread around the Internet, that has already FACEBOOK with e ( @facebook.com ).

These are some of the features of facebook mail:


  • text messages, chat and email together in a simple conversation

  • On, obtain and use your e-mail address optional Facebook .

  • control who can and who not to contact us through these messages Facebook using privacy settings.

  • Observe everything you've talked to a contact or number in the same conversation.

  • e-mail messages from people who do not know and mass emails are automatically placed in another folder.

  • The spam is automatically hide.


  • I'll leave the address for you to explore: www.facebook.com/about/messages/

    Monday, November 8, 2010

    Messages Write Christening Card



    guerrilla advertising.
    Recall that l a guerrilla advertising campaign is that unconventional attempts to obtain the highest degree of public response to the minimum possible resources.

    Can Woolite Be Used In Front Load Washer



    Friday, November 5, 2010

    Recipe For Popcorn Like Garretts'

    FREE ADVERTISING Snake, the snake game video

    When it comes to classic video games, Snake is one of those who has the first place, this game was born around the late 70, and till today has survived and been seen around the world despite new generations remember the Super Mario Bros. or Pac-man.

    Snake is so simple to play, and a snake is that we must feed, collecting objects that make it increase in length. The problem is that if we run into our own body or against the edges. of the screen, we die. And to prevent this, we find it more difficult as the snake grows in size.



    incredible thing to occupy the first place.

    Friday, October 8, 2010

    Barbie, Strawberry Shortcake

    Oracle Direct Insertion (DIRECT INSERT)

    direct insertion of records in tables are made with INSERT and MERGE statements (the insert) or an application that uses OCI direct interface (eg sqlloader). When you need to insert a large amount of rows in an optimum time, it is necessary to sacrifice some functionality at the expense of speed. The performance improvement in the insertion is not free and there are certain requirements that must be met and certain consequences to consider before using. Direct insertion activated in two ways:

    - Adding hint / * + APPEND * / in the INSERT INTO ... SELECT ..
    - Adding hint / * + APPEND * / INSERT INTO .. VALUES .. (In 11g R1)
    - Adding hint / * + APPEND_VALUES * / INSERT INTO .. VALUES .. (In 11g R2)
    - Running the parallel insert

    In the following cases can not use the direct insertion

    - The table has a trigger to modify active trip with inserts.
    - The table has a foreign key change enabled. - The table is a table indexed change.
    - The table to modify is stored in a cluster. - The table contains column change type object type.


    Then I compare the normal insert with putting direct focus on redo and undo space consumed in each case. Also I will show how the direct mode "miss" the cache buffer. Just this last is the key to accelerating the inserts, as new blocks are put together in memory and added to the table directly without using the cache. During the insertion does not increase the HWM and only updates the commit the transaction. For this reason you can not perform any additional operation on the modified table until it has been confirmed directly insert transaction. If we try to execute any statement that references a table after inserting direct mode Oracle generates the error: "ORA-12838: Unable to read / modify an object after modifying it in parallel."

    For example I create a table T with two columns. I'll use a column CHAR (500) to be used more blocks without having to load many rows.
     


    drop table t create table t (x int, and char (500))



    Now inserting 100000 records in the normal way: INSERT


    ---------- CONVENTIONAL ---------


    insert into t select rownum, dbms_random.string ('a', 20)
    from dual connect by rownum


    The insert delayed: 10.8 seconds.

    select round (ms.value/1024/1024)
    redo_size from v $ MYSTAT ms, v $ statname

    WHERE sn = sn.STATISTIC ms.STATISTIC # #
    and sn.NAME = 'redo size'
    redo
    The amount used was: SELECT
    53MB

    t . used_ublk undo_size
    * 8 \u200b\u200bFROM v $ transaction t, v $ session s WHERE
    t.addr = s.taddr
    AND s.audsid = userenv ('sessionid') 1104k


    undo
    The amount used was: 1104Kb


    With this query we check if the buffer was used for the insert:


    select count (1)
    from v $ bh bh, b
    WHERE user_objects
    bh.OBJD = ob.data_object_id
    and ob.object_name = 'T'
    and bh.STATUS! = 'free'
    and bh.CLASS # = 1




    7174 blocks all blocks are loaded into cache for insertion.

    Let's see what happens with the direct mode insert: INSERT DIRECT





    -------------- insert / * + APPEND * / into t select rownum
    , dbms_random.string ('a', 20) 
    from dual connect by rownum


    10.3s


    It took only five seconds less than the conventional insert. This can become discouraged to use direct mode, and you do not see much improvement, but it is important to note that the time difference is going to notice more when we work with a number of records Most importantly, I would say the order of millions.


    select round (ms.value/1024/1024) redo_size
    from v $ MYSTAT ms, v $ statname
    WHERE sn = sn.STATISTIC ms.STATISTIC # #
    and sn.NAME = 'redo size'

    now consumed a little more redo, but see the undo:



    t.used_ublk SELECT * 8 FROM undo_size AND s.audsid = userenv ('sessionid')

    8kb


    With direct insert only 8k undo consumed, ie 138 times less than with the conventional insert.



    select count (1)
    from v $ bh bh, b
    WHERE user_objects
    bh.OBJD = ob.data_object_id
    and ob.object_name = 'T'
    and bh.STATUS! = 'free'
    and bh.CLASS # = 1



     0 Blocks were not used cache blocks, precisely this was expected because as I said above does not use the direct insert buffer. 
    As seen with the direct insert significantly decreased undo space. To reduce the redo must also perform the insert on a table that has disabled the logging, ie is in NOLOGGING (if the base is in NOARCHIVELOG already have disabled the logging for the tables cdo is inserted into live mode).


    INSERT DIRECT NOLOGGING

    --------------------------------- insert / * + APPEND * / into t
    select rownum, dbms_random.string ('a', 20)
     from dual connect by rownum 


    9.6s


    was reduced insertion time, was now 9.6s
    <= 100000

    select round (ms.value/1024 / 1024) from v $ redo_size MYSTAT
    ms, v $ statname

    WHERE sn = sn.STATISTIC ms.STATISTIC # #
    and sn.NAME = 'redo size'

    0


    redo consumption was zero. While this sounds very good, we must bear in mind that disable logging (actually is minimized, since internal operations run HWM or add Extent generate redo and undo) causes to an event of failure we can not perform recovery of newly inserted data. It is advisable to perform a logical backup of the tables or a RMAN incremental backup immediately after the direct load. You can not bypass the redo for tables housed in tablespaces to force logging.


    select round (ms.value/1024/1024) redo_size
    from v $ MYSTAT ms, v $ statname

    WHERE sn = sn.STATISTIC ms.STATISTIC # #
    and sn.NAME = 'redo size'

    8 kb

    undo remained exactly the same as the previous test.
     
    select round (ms.value/1024/1024) from
    redo_size v $ MYSTAT ms, v $ statname

    WHERE sn = sn.STATISTIC ms.STATISTIC # #
    and sn.NAME = 'redo size'

    0 blocks


    nor is loaded into memory blocks.

    Recall that for the 3 previous tests used a table without indexes. Let's see what happens when you add an index to the table T

     
    t_idx create index on t (x)

    insert / * + APPEND * / into t select rownum
    , dbms_random.string ('a', 20)
    from dual connect by rownum

    <= 100000
    11.2.s

    Clearly the insert delayed, but since you had to keep the index updated during insertions.

     select round (ms.value/1024/1024) redo_size 
    from v $ MYSTAT ms, v $ statname

    WHERE sn = sn.STATISTIC ms.STATISTIC # #
    and sn.NAME = 'redo size'

    7

    redo space now consumed was 0, remains little but now it's 7kb, as he had to store redo information for the index. SELECT


    undo_size
     t.used_ublk * 8 FROM v $ transaction t, v $ session s WHERE 
    t.addr = s.taddr
    AND s.audsid = userenv ('sessionid')

    1600 kb


    The undo consumption also increased since records were kept for the new index undo
    tablita
    The following summarizes the results of the tests:

     




    In summary, I recommend using wherever possible the direct mode especially when you need to bulk load (ETL processes) and performance on load is the main objective. Also, if possible, and being aware of what it means to use NOLOGGING, we also recommend configuring the receiving table in NOLOGGING. Finally, you should disable the indices (put them into unusable) because as we saw in the latter case, the maintenance of the indices during insertion generates more undo / redo and slows the overall burden. After the insertion will be to rebuild the indexes unusable.


    Wednesday, September 22, 2010

    Very Thick Cervical Muscus Like Jelly

    As an estimate of capacity and scalability of CPU and I / O (Capacity Planning)

    In this paper I will show you how to perform a Capacity Planning (CP) of CPU and I / O in a simple manner using simple math. To make an effective CP is important to determine the sub-modeling. The subsystems are typical CPU, I / O or disks, memory and network. There are commercial products that allow a global PC without having to model for the subsystem, but I prefer to analyze each subsystem separately because I think that the results are more precise and clear. The CPU and I / O are clearly the most important are the subsystems in which we delve into this note. Surely

    once your manager has asked them if the number of processors or the disk speed is adequate to ensure that the system remains stable. To this question one can answer just be confident and everything will work well or one can be more professional and do a PC and know exactly where it will be the breaking point, ie not only answer if the HW supports the current load but also, taking the annual growth forecast transacccional, to know where we reached our HW and predict in advance the purchase or upgrade of HW.
    now go directly to see how modeling a CPU subsystem and a subsystem of i / o. To perform more sophisticated CP must have some knowledge of queuing theory (Erlang C function, Kendall notation, etc). In this note simply achieved with a little discretion. Figure A) is modeled CPU subsystem. This consists of a single queue and N servers (CPU's). This means that each request can be served by any server arbitrarily or gluing cpu and go when all the CPU is busy (runqueue in terms of OS). Figure B) is modeled subsystem I / O where we have a queue per server or device. In this case, each petition must be served by a particular device.

     



    The two models mentioned are represented many times in daily life, when we go to the bank, when we are waiting at the toll booth, as we wait to board a flight, when we place our order in a restaurant de comida rapida, etc.

    Ahora vamos a definir las variables que necesitamos usar para realizar el CP:
    <= 100000

    Uc= User Calls
    trx= transacción
    λ= tasa de arribo (ej: trx/ms ó Uc/ms)
    St= Tiempo de Servicio (ej: s/trx ó s/Uc)
    Qt= Tiempo de Espera o Tiempo de espera (ej: s/trx)
     Rt= Tiempo de Respuesta  (ej: s/trx) 
    Q= Encolamiento (ej: Nro de trx's)
    U= porcentaje de carga (porcentaje de utlización del recurso)
    M= nro de servers (cantidad de CPU's o cantidad de IO devices)

    y las formulas:

    Rt = St + Qt
    U = St * λ / M
    Q = λ *
     
    Qt Rt (cpu) = St / (1-U ^ M)

    Rt (io) = St / (1-U)



    The goal is to graph the response time vs arrival rate. The graph should be exponential with a curve or turning point that shows that arrival rate (X axis) occurs the break.


     

    I will explain more in detail what each thing means:

    1) λ (Arrival Rate): This metric can be defined with Oracle such as: Uc / s Trs / s, or using functional metrics, eg purchase order charge per minute or per hour.

    2) M (Quantity of CPU'sy I / O Devices): The number of CPU's or I / O Devices. To obtain this value we can use OS utilities and / or consult Oracle views.

    3) U (Percent Charge): The percentage of CPU load or I / O. This can be achieved using OS utilities such as sar, iostat.

    4) St (service time): The time in which the request is being handled by the CPU or the device i / o.

    5) Qt (Waiting Time Tail): The time that a request has to wait in line because the servers are busy.

    6) Q (Long Tail): The number of requests queued (waiting to be served)
     7) Rt (Time response): The response time is the sum of St (service time) and Qt (timeout or bonding). A request or is waiting or being served. 

    At this point, where I have defined all, I'll show you an example: Example



    (Capacity Planning CPU) <= 100000


    Suppose we are asked to estimate the impact that increases will occur if the user of an application X by 20%. What we want to determine is whether you need to add more processors or what is good enough to support the additional load.

    first thing we do is collect information on a representative period. The more data we collect more accurate will be our CP, then we must characterize the load, this means defining whether we will use average values, maximums, which we will use as arrival rate, etc. In the example I'm going to have peak values \u200b\u200bin the range of maximum load and a rate up using Trx / s.
     λ = 20 trx / s (20 transactions per second, is available from Statspack or AWR) 
    U = 0.40 (40% cpu utilization, it can be collected with sar-u)
    M = 8 ( there are 8 processor then, is obtained from the parameter of the base: cpu_count)

    Since I have the 3 essential parameters, only now I have to apply the formulas and graph:



    St * U = λ / M, depejando for St, St

    = U * M / λ = 0.40 * 8 / 20 = 0.16 s / trx
    St
     Now we can apply the formula for cpu: 



    Rt (cpu) = St / (1 -U ^ M) = 0.16 / (1-0.40 ^ 8) = 0.16 s / trx

    As seen the response time equals the time of service. This is because the system is loose in CPU for the current load and there is no queuing, ie wait to be served by the cpu's. Now what I do is a table in excel to project and plot the growth curve in order to see where the break occurs.





    see that the turning point is around 30-35% (>), consider also that we are starting from a peak workload, and therefore we think that most of the time will be well below. According to CP can be sure that the damper system while the additional burden of 20%, beginning to deteriorate rapidly from 25%.


    Example 2 (Capacity Planning for I / O) As discussed in Example 1, we would not have major problems with the cpu to a 30% increase in load. Now let's see what happens with the discs.

    5Mb/ms λ = (5 Mb transfer per millisecond can be obtained with sar-do iostat)
    U = 0.60 (60% usage of i / o)
    M = 50 (there are 50 devices)

    St = U * M / λ = 50 * 0.60 / 5 = 6 ms / Mb Replacing in the formula i / o:
    Rt (io) = St / (1 -U) = 6 / (1-0.60) = 15ms/Mb



     


    As shown in the graph, the system could support up to 50% (7.5Mb/ms) of growth, once reaches 60% of destabilizes.

    In summary we can conclude that our hardware is well at both non-cpu i / o as long-term will not scale. This paper

    my idea was to show how to make a cpu capacity planning yi / or easily. With this method we have a good estimate how to escalate our HW. According to each case, there are other approaches such as modeling method based on ratios, queuing theory and linear regression method.

    most important for accurate estimates is to obtain a sample that is representative joined a good characterization of the workload to be assessed. The more information we have collected better prognosis.

    Using this methodology can perform simulations and future projects, for example, what if we add or we get cpu's, how it impacts the aggregate device i / or faster, with higher throughput and lower latency, few users could add to operate with application without compromising system stability, etc.

    To those of interest issues in Oracle Capacity Planning I recommend:



    "Forecasting Oracle Performance"
    . This book by Craig Shallahamer, a real guru on the subject, was excellent and I used it as reference to write the note.

    Monday, September 20, 2010

    Can I Join The Military If I Have Ezcema

    Optimizing statistical collection on partitioned tables


    Oracle 10g uses a two pass algorithm to collect statistics on partitioned tables:

    1. One pass over the entire table to update the global statistics. 2. A second pass to collect statistics on each of the partitions.

    This approach has the disadvantage that if changes are made in a few partitions to make them eligible for automatic collection maintenance window, as well as update an own partition statistics in question, it must perform the global update of the table. For the latter it runs the entire table, including partitions did not change. This can be done very heavy depending on the size of the table.
    From Oracle 11g adopting a one-pass algorithm, so that instead of making one pass around the table to update the global information, it performs an incremental update inferring changes from the modified partition. Some of statistics can be derived easily from the statistics of the partitions (eg the number of rows), but other statistics, such as the number of distinct values \u200b\u200bin a column no. To resolve this Oracle uses a new structure called a synopsis for each column at the level of the partition so that the number of distinct values \u200b\u200b(NDV) globally can be derived by merge of the synopsis of the partitions analyzed.







    While this is a feature of 11g R1, Oracle 10g R2 10.2.0.4 more precisely on an option to simulate the incremental collection through a new value 'APPROX_GLOBAL AND PARTITION' for the parameter in the procedure GATHER_TABLE_STATS GRANULARITY. Their behavior is equal to 11g
    except for the NDV of the column is not partitioned and the number of keys than the global index.

    incremental maintenance is disabled by default and can be enabled at the table, schema, even at the level of the database.

    Then I pass the results of my tests using Oracle 11g R1 (11.1.0.7):

    I'll use a table partitioned by date range with 3 partitions. The table is small (about 5M rows) but serve to illustrate:


    select partition_name,
    num_rows from table_name WHERE user_tab_partitions = 'T';
    partition_name
    NUM_ROWS ---------- ------------------------------
    P0810 2583379 P0710 1332466 P0910 1084155

    PMAX 0


    100.000
    I will delete records in a partition:


    delete from t partition (p0910) WHERE rownum

    update statistics, using the default, ie without incremental collection:


    begin
    dbms_stats.gather_table_stats (ownname => user, tabname => 'T');
    end;
    Procedure PL / SQL completed successfully. Elapsed: 00:00:11.71




    took almost 12 seconds.
    select dbms_stats.get_prefs ('INCREMENTAL', tabname => 'T') from dual; FALSE

    With

    above query was verified that the conventional collection

    Now I will turn the collection on table T and I delete rows and I will return to collect the statistics:
    begin
    dbms_stats.set_table_prefs (ownname => user, tabname => 'T',
    pname => 'INCREMENTAL', pvalue => 'TRUE' )
    end;


    actually verified that the incremental mode is activated on the table T:


    select dbms_stats.get_prefs ('INCREMENTAL', tabname => 'T') from dual;
    TRUE


    begin dbms_stats.gather_table_stats (ownname = > user, tabname => 'T'); end;

    Elapsed: 00:00:04.71


    Now

    took 4s. Instead of going through the whole table looked just changed the partition and then derived the global statistics based on the changes and using the synapses of the partition.

    must take into account the global histograms are not preserved after run incremental collection (see Bug 8686932 in Metalink).

    While this method used by Oracle to make more effective the collection has been studied in academic and laboratory time ago, is Oracle's first relational database engine to implement it.


    Tuesday, August 24, 2010

    How To Congratbar Mitzvah

    How to get the edition of the software installed from the inventory

    For edition (Enterprise or Standard) of the Oracle software (engine) installed, if still not created a database (you can remove the issue from the catalog of the base) and if the person who installed it can not remember which option chosen, you can run the following command from Unix / Linux you are looking for in the inventory: $ grep-w $ s_serverInstallType ORACLE_HOME/inventory/Components21/oracle.server / * / context.xml of statistics and system objects. This new feature is very useful to analyze the impact of change as it allows to "play" with the environment and easily make comparison reports, regression testing, impact load, etc.
    I will create a table with 1M records T and PCTFREE 90% to consume many blocks such that the difference between the performances that I compare it more noticeable. Then I'll create a PK for the id field. With RBO will do a FULL SCAN on the table T, which does not realize that has a PK and I could do a full index scan is faster. CBO obviously realizes this as being just PK has the same amount of records to the table and therefore serves to answer the question of how many records have the table T.


    create table t (id int, val varchar2 (10)) PCTFREE 90;


    insert into t select rownum as, dbms_random.string ('a', 10)
    from dual connect by rownum

    alter table t add primary key (id);


    test carried out the sentence, use a hint to be more easily located in the dynamic view and get your sqlid:


    select count (1) / * + * Test SPA / from t;


    sql_id select from v $ sql WHERE
    sql_text like '% SPA% Proof' and sql_text NOT LIKE '% sql_text%';

     5r2ufj2vqkk4p 

    I have the sqlid
    already, so I'm going to do is build a SQL Tuning Set (STS) using DBMS_SQLTUNE package (that has existed for 10g, so I could do in 10g and then migrate it to 11g, for example, to evaluate an upgrade between those versions)


    begin
    dbms_sqltune.create_sqlset (sqlset_name => 'Test', description => 'Test STS');
    end;

    The STS test you create is called, now has charge of the sentence from memory cursor: DECLARE


     l_cursor DBMS_SQLTUNE.sqlset_cursor ; 

    BEGIN OPEN l_cursor <= 100000; 100000 filas suprimidas.
    FOR SELECT VALUE (p) FROM TABLE
    (
    DBMS_SQLTUNE.select_cursor_cache (
     '5r2ufj2vqkk4p sql_id =''''', - basic_filter 
    NULL, - object_filter
    NULL, - NULL
    ranking_measure1 - ranking_measure2
    NULL, - NULL
    ranking_measure3 - result_percentage
    1) - result_limit ) p;
    DBMS_SQLTUNE.load_sqlset (
    sqlset_name => 'test',
    populate_cursor => l_cursor)
    END;
     

    actually verified that the STS has been created and contains the sentence :

    user_sqlset select * from WHERE name = 'Test';



    ----------------------------- NAME ID - ---------- ------------------------------------
     
    DESCRIPTION CREATED
    ------------------------------------------------ STATEMENT_COUNT LAST_MODI

    Test --------- --------- --------------- 10
    Test STS 12-AUG-10 12-AUG-10 1

    select sqlset_name, sql_id from user_sqlset_statements WHERE r2ufj2vqkk4p sql_id = '5 ';
     SQLSET_NAME 
    SQL_ID
    ------------- Test ------------- -----------------
    5r2ufj2vqkk4p



    At this point, and having created the STS, which contains the but the sentence context information to evaluate it, we can begin to use the package DBMS_SQLPA (there from 11g R1) for comparison. For example DBMS_SQLTUNE and DBMS_SQLPA packages are complementary. With the first harmonized the workload (which may contain one or more sentences obtained from the AWR, from a cursor, from another STS or even from a trace file) and the second conducted comparative analysis (benchmarking). Then see how to perform this analysis: First

    created a task analysis:

    l_out declare char (50);

    begin l_out: = dbms_sqlpa.create_analysis_task (
    sqlset_name => 'test',
    task_name => 'Prueba_TSK');
    end;
    Then, set up to simulate the environment "before." In our example, the idea is to compare a count with RBO and CBO, so setpoints at the meeting, the optimizer to use RBO and run the analysis with their environment:


    alter session set optimizer_mode = RULE;


    begin DBMS_SQLPA.EXECUTE_ANALYSIS_TASK (
    task_name => 'Prueba_TSK'
    execution_type => 'TEST EXECUTE',
    execution_name = > 'Prueba_EXEC_antes');

    I do the same to compare the "after" Setting Up the optimizer to its default value in 11g:


    alter session set optimizer_mode = ALL_ROWS;
    begin
    DBMS_SQLPA.EXECUTE_ANALYSIS_TASK
    (
    task_name => 'Prueba_TSK'
    execution_type => 'TEST EXECUTE ',
    execution_name =>' Prueba_EXEC_despues');
    end;
     
    To compare, you can set focus on that metric, if not clarified anything, it is used as a metric of comparison: "elapsed_time." In this example I chose to use "buffer_gets", as this metric is one that most changes between the two cases to compare and therefore makes more compelling the final report. BEGIN



    DBMS_SQLPA.set_analysis_task_parameter ('Prueba_TSK'
    'comparison_metric' <= 1000000 ;
    'buffer_gets');
    END;

    executed on the master for the sp Comparison: BEGIN


     DBMS_SQLPA.execute_analysis_task (
    task_name => 'Prueba_TSK'
    execution_type => 'compare performance',
    execution_params => dbms_advisor.arglist (
    'execution_name1'
    'Prueba_EXEC_antes'
    ' execution_name2 '
    ' Prueba_EXEC_despues')
    )
    END;


    Once we ran the analysis using a summary report of the differences:
     


    SET LONG 1000000 SET PAGESIZE 0 SET LINESIZE 200
    LONGCHUNKSIZE SET 200
    SET TRIMSPOOL ON
     rop@DESA11G> SELECT DBMS_SQLPA.REPORT_ANALYSIS_TASK('Prueba_TSK', 'TEXT', 'TYPICAL', 'SUMMARY') from 
    dual;
    General Information
    ---------------------------------------------------------------------------------------------

    Task Information: Workload Information:
    --------------------------------------------- ---------------------------------------------
    Task Name : Prueba_TSK SQL Tuning Set Name : Prueba
    Task Owner : ROP SQL Tuning Set Owner : ROP
    Description : Total SQL Statement Count : 1

    Execution Information:
    ---------------------------------------------------------------------------------------------
    Execution Name : EXEC_7692 Started : 08/12/2010 16:27:22
    Execution Type : COMPARE PERFORMANCE Last Updated : 08/12/2010 16:27:22
    Description : Global Time Limit : UNLIMITED
    Scope : COMPREHENSIVE Per-SQL Time Limit : UNUSED
    Status : COMPLETED Number of Errors : 0

    Analysis Information:
    ---------------------------------------------------------------------------------------------
    Comparison Metric: BUFFER_GETS
    ------------------
    Workload Impact Threshold: 1%
    --------------------------
      SQL Impact Threshold: 1% 
    ----------------------
    Before Change Execution: After Change Execution:
    --------------------------------------------- ---------------------------------------------
    Execution Name : Prueba_EXEC_antes Execution Name : Prueba_EXEC_despues
    Execution Type : TEST EXECUTE Execution Type : TEST EXECUTE
    Scope : COMPREHENSIVE Scope : COMPREHENSIVE
    Status : COMPLETED Status : COMPLETED
    Started : 08/12/2010 16:26:29 Started : 08/12/2010 16:27:04
    Last Updated : 08/12/2010 16:27:13 Last Updated : 08/12/2010 16:27:13
    Global Time Limit : UNLIMITED Global Time Limit : UNLIMITED
    Per-SQL Time Limit : UNUSED Per-SQL Time Limit : UNUSED
    Number of Errors : 0 Number of Errors : 0

    Report Summary
    ---------------------------------------------------------------------------------------------

    Projected Workload Change Impact:
    -------------------------------------------
    Overall Impact : 92.05%
    Improvement Impact : 92.05%
    Regression Impact : 0%

    SQL Statement Count
    -------------------------------------------
    SQL Category SQL Count Plan Change Count
      Overall               1                  1 
    Improved 1 1

    Top SQL Statements Sorted by their Absolute Value of Change Impact on the Workload
    --------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------------------------------

    'TEXT', 'TYPICAL', 'FINDINGS') from dual;
    General Information
    ---------------------------------------------------------------------------------------------

    Task Information: Workload Information:
    --------------------------------------------- ---------------------------------------------
       Task Name    : Prueba_TSK                      SQL Tuning Set Name        : Prueba 
    Task Owner : ROP SQL Tuning Set Owner : ROP
    Description : Total SQL Statement Count : 1

    Execution Information:
    ---------------------------------------------------------------------------------------------
    Execution Name : EXEC_7692 Started : 08/12/2010 16:27:22
    Execution Type : COMPARE PERFORMANCE Last Updated : 08/12/2010 16:27:22
    Description : Global Time Limit : UNLIMITED
    Scope : COMPREHENSIVE Per-SQL Time Limit : UNUSED
    Status : COMPLETED Number of Errors : 0

    Analysis Information:
    ---------------------------------------------------------------------------------------------
      Comparison Metric: BUFFER_GETS 
    ------------------
    Workload Impact Threshold: 1%
    --------------------------
    SQL Impact Threshold: 1%
    ----------------------
    Before Change Execution: After Change Execution:
    --------------------------------------------- ---------------------------------------------
    Execution Name : Prueba_EXEC_antes Execution Name : Prueba_EXEC_despues
    Execution Type : TEST EXECUTE Execution Type : TEST EXECUTE
    Scope : COMPREHENSIVE Scope : COMPREHENSIVE
    Status : COMPLETED Status : COMPLETED
    Started : 08/12/2010 16:26:29 Started : 08/12/2010 16:27:04
       Last Updated        : 08/12/2010 16:27:13      Last Updated        : 08/12/2010  16:27:13 
    Global Time Limit : UNLIMITED Global Time Limit : UNLIMITED
    Per-SQL Time Limit : UNUSED Per-SQL Time Limit : UNUSED
    Number of Errors : 0 Number of Errors : 0

    Report Details: Statements Sorted by their Absolute Value of Change Impact on the Workload
    ---------------------------------------------------------------------------------------------

    SQL Details:
    -----------------------------
      Object ID            : 4 
    Schema Name : ROP
    SQL ID : 5r2ufj2vqkk4p
    Execution Frequency : 1
    SQL Text : select count(1) /*+ Prueba SPA */ from t

    Execution Statistics:
    -----------------------------
    ------------------------------------------------------------------------------------------------



    Elapsed: 00:00:00.59


     The trivial example a comparison of the SPA procedure using sqlplus only (you could use MS to a more visual comparison), but serve to illustrate its usefulness. Using a similar procedure could make a pre-upgrade analysis to help ensure the stability of post-upgrade critical judgments on a 11g. To do so would have to perform the following steps before the analysis with SPA: 

    1. Create the STS at the base to Upgrade

    If the upgrade is based on 10g you can create the STS from AWR determining a representative range of the load. If the upgrade is based on 9i STS can be obtained from a previous trace 9i generated during a real load range.

    then show an example, which is in the official documentation 10g to create a STS
    from AWR, using a previously established baseline for a range with maximum load "peak baseline ', and filtered for the STS only include statements that are executed more than 10 times and a ratio between disk reads and buffer gets over 50%. It also specifies that TOP collect the 30 sentences ordered by disk_reads / buffer_gets: DECLARE



    baseline_cursor DBMS_SQLTUNE.SQLSET_CURSOR;

    BEGIN OPEN baseline_cursor
    FOR SELECT VALUE (p) FROM TABLE
    (DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY (
    'peak baseline',
    'Executions> = 10 AND disk_reads / buffer_gets> = 0.5', NULL
    ,
    'disk_reads / buffer_gets'
    NULL, NULL, NULL,
    30)) p;

    DBMS_SQLTUNE.LOAD_SQLSET (
    sqlset_name => 'my_sql_tuning_set'
    populate_cursor => baseline_cursor)
    END;


    If not I create a baseline, also can be configured using two AWR snapshosts id to specify the range to be processed.

    2. STS migrate to the new base (11g)


    - Create table to store the STS stage and then transferred to the new base

    begin DBMS_SQLTUNE.create_stgtab_sqlset (table_name => 'TBL_STG_STS'
    schema_name => user);
    end;





    - Record STS in the table begin
    DBMS_SQLTUNE.pack_stgtab_sqlset
    stage (sqlset_name => 'test',
    staging_table_name => 'TBL_STG_STS');
    end;


    Once created and charged the stage table, subtract pass to the new base. Here you can use data pump or exp / imp conventional.



    - Creates the STS generated in 10g from the stage table in 11g
    begin
    DBMS_SQLTUNE.unpack_stgtab_sqlset (sqlset_name => 'test',
    staging_table_name => 'TBL_STG_STS'
    replace => TRUE);
    end;



    In short, we may use this procedure for quickly assessing the impact of changes on the sentences, and therefore in the implementation plans, due to changes in the environment, for example, change of equipment, disks, cpu add, change database version changes in parameterization, etc.
    can "play" with different settings and see how it sentences, perform benchmarking and analysis with different strategies and parameterizations, etc and so to infer the pre-change behavior and prevent instability of the applications when it is too late to turn back implies a high cost.