It was a good for me with reading a good book that was written by C.J. Date, he is an independent author, lecturer, researcher, and consultant, specializing in relational database technology. He is best known for his book An Introduction to Database Systems (8thedition, Addison-Wesley, 2004), which has sold nearly 900,000 copies at the time of writing and is used by several hundred colleges and universities worldwide.
I was talking about a book tittles Relational Theory for Computer Professionals What Relational Databases Are Really All About By C.J. Date.
This is a good book for some people who are interested in Relational Database, and who want to know what exactly Relational Database is all about. Anyway, readers should have a basic about relational database. If You don't have... you should read other books from C.J. Date before. Why I said like that, I think this book not easy to read if you don't have basic and no idea about relational database. By the way, you might read "Free Sampler" before.
A book has 3 parts, Part I, "Foundations" is concerned with the relational model. Part II, “Transactions and Database Design,” is devoted to a discussion of certain material that (a) you do need to know in order to understand what databases in general, and relational databases in particular, are all about, but (b) doesn’t really have all that much to do with the relational model. Part III, “SQL,” then revisits the material of Part I and shows how the concepts discussed in that first part are realized in the SQL language.
In a book, after you finished for reading each chapter you can see exercise to help you to improve your understanding, that's very cool anyway. This book is useful to use in college, but I think that should be advance course because it need basic about relational database and sql. Something pops up in my head ... watch Relational Theory for Computer ProfessionalsA Hands-On Video WorkshopBy C.J. Date, that will help you too much in a book.
Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts
Wednesday, June 12, 2013
Monday, January 02, 2012
SQL and Relational Theory, 2nd Edition by C.J. Date

What is Relational model? The relational model for database management is a database model based on first-order predicate logic. The purpose of the relational model is to provide a declarative method for specifying data and queries.
If You work with database as either Database Administrator or Database Developer. You'd supposed to know about SQL and Relational model. If you interest and wish to learn about SQL and Relational Theory, I'd recommend SQL and Relational Theory, 2nd Edition How to Write Accurate SQL Code By C. J. Date
However, This book doesn't teach you about SQL statements.
In 2nd Edition, that includes new material on recursive queries, “missing information” without nulls, new update operators, and topics such as aggregate operators, grouping and ungrouping, and view updating. It also includes "A Tutorial D Grammar" in appendix.
1st Edition:
Appendix The Relational Model
Appendix Database Design Theory
Appendix Answers to Exercises
Appendix Suggestions for Further ReadingTRIBUTES / A NOTE ON RECURSION
2nd Edition:
Appendix The Relational Model
Appendix SQL Departures from the Relational Model
Appendix A Relational Approach to Missing Information
Appendix A Tutorial D Grammar
Appendix Summary of Recommendations
Appendix Answers to Exercises
Appendix Suggestions for Further Reading
If you are looking for Normal Forms. You should wait book - "Normal Forms and All That Jazz: A Database Professional's Guide to Database Theory".
This book is useful for SQL and Relation. It will help you for some questions. Example:
1. What exactly is first normal form?
2. What's the connection between relations and predicts?
3. What's semantic optimization?
4. What's an image relation?
5. Why is semidifference important?
6. Why doesn't deferred integrity checking make sense?
7. What's a relation variable?
8. What's prenex normal form?
9. Can a relation have an attribute whose values are relations?
10. Is SQL relationally complete?
11. Why is The Information Principle important?
12. How does XML fit with the relational model?
Before You get this book, you should know what you interest and what this book can help you. I'd recommend you check it link.
In this book, you will learn about Relational model; Types and Domains, Tuples and Relations, Rows and Tables, No Duplicates, No Nulls, Base Relvars, Base Tables, SQL and Relational Algebra + Constraints +Views ,... that's all many contents, ideas and examples. You will learn SQL and Relational theory from Professional. When you read each chapter finish, you will see "Exercise", that will help you memorize and understand more. It has well-formed paragraphs and many references; it's good for readers. I believe this book is useful for DBAs, students and someone who interests in SQL and Relational.
However, You can get VIDEO - C.J. Date's SQL and Relational Theory Master Class How to Write Accurate SQL Code
C.J. Date is is an independent author, lecturer, researcher, and consultant, specializing in relational database theory. Other books:
- An Introduction to Database Systems, ISBN 0-321-19784-4
- Databases, Types, and the Relational Model, The Third Manifesto (with Hugh Darwen), ISBN 0-321-39942-0
- Temporal Data & the Relational Model, ISBN 1-55860-855-9
- Database in Depth: Relational Theory for Practitioners, ISBN 0-596-10012-4
- Several editions of Relational Database Writings, ISBN 0-201-39814-1, ISBN 0-201-82459-0, ISBN 0-201-54303-6, ISBN 0-201-50881-8.
- What Not How: The Business Rules Approach to Application Development, ISBN 0-201-70850-7
- The Database Relational Model: A Retrospective Review and Analysis, ISBN 0-201-61294-1
- SQL and Relational Theory, 2nd Edition: How to Write Accurate SQL Code, ISBN 1-4493-1640-9
Related Post:
SQL and Relational Theory Master Class (How to Write Accurate SQL Code) by C.J. Date
Saturday, August 27, 2011
Just learned - Real-Time SQL Monitoring
I interest some topic in "Oracle Database 11g Performance Tuning Recipes A Problem-Solution Approach" book. Real-Time SQL Monitoring. How? This is 11g feature.
MONITOR : To force real-time SQL monitoring
Or if
NO_MONITOR : To prevent the query from being monitored
How to monitor?
You can use V$SQL_MONITOR and V$SQL_PLAN_MONITOR views to monitor the statistics.
The V$SQL_MONITOR view contains a subset of the statistics available in V$SQL.
The V$SQL_PLAN_MONITOR view contains plan level monitoring statistics for each SQL statement in V$SQL_MONITOR.
What should you know from both views?
KEY NUMBER : Artificial join key to efficiently join V$SQL_MONITOR with its corresponding plan level monitoring statistics stored in V$SQL_PLAN_MONITOR.
STATUS : SQL execution status. Values are below :
■ EXECUTING - SQL statement is still executing
■ DONE (ERROR) - Execution terminated with an error
■ DONE (FIRST N ROWS) - Execution terminated by the application before all rows were fetched
■ DONE (ALL ROWS) - Execution terminated and all rows were fetched
■ DONE - Execution terminated (parallel execution)
Tested!!!
- On some session:
- Find information from SQL statement
- Find Execution Plan
However, If You checked by "dbms_sqltune.report_sql_monitor"
SQL monitoring is automatically started when a SQL statement runs parallel or when it has consumed at least 5 seconds of CPU or I/O time.Before you will use this feature, your database have to have "statistics_level" = TYPICAL or ALL, "control_management_pack_access"=DIAGNOSTIC+TUNING
SQL> show parameter statistics_levelWhen you need to test Real-Time SQL Monitoring, you can use HINTS:
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
statistics_level string TYPICAL
SQL> show parameter control_management_pack_access
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_management_pack_access string DIAGNOSTIC+TUNING
MONITOR : To force real-time SQL monitoring
Or if
NO_MONITOR : To prevent the query from being monitored
How to monitor?
You can use V$SQL_MONITOR and V$SQL_PLAN_MONITOR views to monitor the statistics.
The V$SQL_MONITOR view contains a subset of the statistics available in V$SQL.
The V$SQL_PLAN_MONITOR view contains plan level monitoring statistics for each SQL statement in V$SQL_MONITOR.
What should you know from both views?
KEY NUMBER : Artificial join key to efficiently join V$SQL_MONITOR with its corresponding plan level monitoring statistics stored in V$SQL_PLAN_MONITOR.
STATUS : SQL execution status. Values are below :
■ EXECUTING - SQL statement is still executing
■ DONE (ERROR) - Execution terminated with an error
■ DONE (FIRST N ROWS) - Execution terminated by the application before all rows were fetched
■ DONE (ALL ROWS) - Execution terminated and all rows were fetched
■ DONE - Execution terminated (parallel execution)
Tested!!!
- On some session:
SQL> select /*+ MONITOR */ * from TB_TEST;During SQL statement is still executing
- Find information from SQL statement
select key, status, username, module ,service_name, sql_text, cpu_time, buffer_gets from v$sql_monitor where status = 'EXECUTING'
/

select plan_line_id id, lpad (' ', plan_depth) || plan_operation operation , plan_options , plan_object_name , plan_cardinality card, plan_cost from v$sql_monitor q, v$sql_plan_monitor p where q.key = p.key and q.key = &KEY order by idKEY= 158913789964
/

SQL> select dbms_sqltune.report_sql_monitor from dual;This is just sample for manually tuning SQL idea. If you need to monitor your SQL. Use it MONITOR hint -)
REPORT_SQL_MONITOR
---------------------------------------------------------------------------------------------------------------------------------
SQL Monitoring Report
SQL Text
------------------------------
select /*+ MONITOR */ * from TB_TEST
Global Information
------------------------------
Status : EXECUTING
Instance ID : 1
Session : DEMO (36:327)
SQL ID : 45fs1021jz1dg
SQL Execution ID : 16777219
Execution Started : 08/27/2011 17:38:05
First Refresh Time : 08/27/2011 17:38:05
Last Refresh Time : 08/27/2011 17:38:06
Duration : 2s
Module/Action : SQL*Plus/-
Service : SYS$USERS
Program : sqlplus@linuxtest01 (TNS V1-V3)
Fetch Calls : 244
Global Stats
=================================================
| Elapsed | Cpu | Other | Fetch | Buffer |
| Time(s) | Time(s) | Waits(s) | Calls | Gets |
=================================================
| 0.08 | 0.06 | 0.02 | 244 | 290 |
=================================================
SQL Plan Monitoring Details (Plan Hash Value=1092599453)
==============================================================================================================================
| Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Activity | Activity Detail |
| | | | (Estim) | | Active(s) | Active | | (Actual) | (%) | (# samples) |
==============================================================================================================================
| 0 | SELECT STATEMENT | | | | | | 1 | | | |
| -> 1 | TABLE ACCESS FULL | TB_TEST | 162K | 597 | 2 | +0 | 1 | 0 | | |
==============================================================================================================================
ป้ายกำกับ:
11g,
11gR2,
oracle,
oradbpedia,
performace tuning,
sql
Sunday, August 21, 2011
Just learn more from V$LOCK
I posted Excessive waited 'SQL*Net message from client' - when query V$LOCK. Thank You for first comment (Marcus). He figured me out about STATE and reviewed EXPLAIN PLAN!!! I want to test it more...
CASE 1: SELECT * FROM V$LOCK
select s.inst_id,l.laddr,l.kaddr,s.ksusenum,r.ksqrsidt,r.ksqrsid1, r.ksqrsid2,l.lmode,l.request,l.ctime,decode(l.lmode,0,0,l.block) from v$_lock l, x$ksuse s, x$ksqrs r where l.saddr=s.addr and concat(USERENV('Instance'),l.raddr)=concat(r.inst_id,r.addr) and s.inst_id = USERENV('Instance');
and tested more ... with this sql statement.
When you omit the
I posted about 'SQL*Net message from client' wrong.... because "MERGE JOIN CARTESIAN" made excessive response time. So, I use : select /*+ ordered */ * from v$lock !!!
Related Post:
Excessive waited 'SQL*Net message from client' - when query V$LOCK
CASE 1: SELECT * FROM V$LOCK
SQL> EXPLAIN PLAN FOR SELECT * FROM V$LOCK;CASE 2: SELECT /*+ PARALLEL */ * FROM V$LOCK
Explained.
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY());
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 554400005
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 156 | 1 (100)| 00:00:04 |
|* 1 | HASH JOIN | | 1 | 156 | 1 (100)| 00:00:04 |
| 2 | VIEW | GV$_LOCK | 10 | 760 | 0 (0)| 00:00:01 |
| 3 | UNION-ALL | | | | | |
|* 4 | FILTER | | | | | |
| 5 | VIEW | GV$_LOCK1 | 2 | 152 | 0 (0)| 00:00:01 |
| 6 | UNION-ALL | | | | | |
|* 7 | FIXED TABLE FULL| X$KDNSSF | 1 | 102 | 0 (0)| 00:00:01 |
|* 8 | FIXED TABLE FULL| X$KSQEQ | 1 | 102 | 0 (0)| 00:00:01 |
|* 9 | FIXED TABLE FULL | X$KTADM | 1 | 102 | 0 (0)| 00:00:01 |
|* 10 | FIXED TABLE FULL | X$KTATRFIL | 1 | 102 | 0 (0)| 00:00:01 |
|* 11 | FIXED TABLE FULL | X$KTATRFSL | 1 | 102 | 0 (0)| 00:00:01 |
|* 12 | FIXED TABLE FULL | X$KTATL | 1 | 102 | 0 (0)| 00:00:01 |
|* 13 | FIXED TABLE FULL | X$KTSTUSC | 1 | 102 | 0 (0)| 00:00:01 |
|* 14 | FIXED TABLE FULL | X$KTSTUSS | 1 | 102 | 0 (0)| 00:00:01 |
|* 15 | FIXED TABLE FULL | X$KTSTUSG | 1 | 102 | 0 (0)| 00:00:01 |
|* 16 | FIXED TABLE FULL | X$KTCXB | 1 | 102 | 0 (0)| 00:00:01 |
| 17 | MERGE JOIN CARTESIAN | | 100 | 8000 | 0 (0)| 00:00:01 |
|* 18 | FIXED TABLE FULL | X$KSUSE | 1 | 32 | 0 (0)| 00:00:01 |
| 19 | BUFFER SORT | | 100 | 4800 | 0 (0)| 00:00:01 |
| 20 | FIXED TABLE FULL | X$KSQRS | 100 | 4800 | 0 (0)| 00:00:01 |
-------------------------------------------------------------------------------------
SQL> EXPLAIN PLAN FOR SELECT /*+ PARALLEL */ * FROM V$LOCK;He told me review "MERGE JOIN CARTESIAN", it can make Excessive fetch data. OK test test test it. then I found out V$LOCK!!!
Explained.
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY());
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 1453144240
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 156 | 1 (100)| 00:00:01 |
|* 1 | HASH JOIN | | 1 | 156 | 1 (100)| 00:00:01 |
|* 2 | HASH JOIN | | 1 | 108 | 1 (100)| 00:00:01 |
|* 3 | FIXED TABLE FULL | X$KSUSE | 1 | 32 | 0 (0)| 00:00:01 |
| 4 | VIEW | GV$_LOCK | 10 | 760 | 0 (0)| 00:00:01 |
| 5 | UNION-ALL | | | | | |
|* 6 | FILTER | | | | | |
| 7 | VIEW | GV$_LOCK1 | 2 | 152 | 0 (0)| 00:00:01 |
| 8 | UNION-ALL | | | | | |
|* 9 | FIXED TABLE FULL| X$KDNSSF | 1 | 102 | 0 (0)| 00:00:01 |
|* 10 | FIXED TABLE FULL| X$KSQEQ | 1 | 102 | 0 (0)| 00:00:01 |
|* 11 | FIXED TABLE FULL | X$KTADM | 1 | 102 | 0 (0)| 00:00:01 |
|* 12 | FIXED TABLE FULL | X$KTATRFIL | 1 | 102 | 0 (0)| 00:00:01 |
|* 13 | FIXED TABLE FULL | X$KTATRFSL | 1 | 102 | 0 (0)| 00:00:01 |
|* 14 | FIXED TABLE FULL | X$KTATL | 1 | 102 | 0 (0)| 00:00:01 |
|* 15 | FIXED TABLE FULL | X$KTSTUSC | 1 | 102 | 0 (0)| 00:00:01 |
|* 16 | FIXED TABLE FULL | X$KTSTUSS | 1 | 102 | 0 (0)| 00:00:01 |
|* 17 | FIXED TABLE FULL | X$KTSTUSG | 1 | 102 | 0 (0)| 00:00:01 |
|* 18 | FIXED TABLE FULL | X$KTCXB | 1 | 102 | 0 (0)| 00:00:01 |
| 19 | FIXED TABLE FULL | X$KSQRS | 100 | 4800 | 0 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
SQL> SELECT VIEW_DEFINITION FROM V$FIXED_VIEW_DEFINITION WHERE VIEW_NAME='V$LOCK';So, SQL statement for V$LOCK!!!
VIEW_DEFINITION
-----------------------------------------------------------------------------------------------------------------------------------------------
select ADDR , KADDR , SID , TYPE , ID1 , ID2 , LMODE , REQUEST , CTIME , BLOCK from GV$LOCK where inst_id = USERENV('Instance')
SQL> SELECT VIEW_DEFINITION FROM V$FIXED_VIEW_DEFINITION WHERE VIEW_NAME='GV$LOCK';
VIEW_DEFINITION
-----------------------------------------------------------------------------------------------------------------------------------------------
select s.inst_id,l.laddr,l.kaddr,s.ksusenum,r.ksqrsidt,r.ksqrsid1,r.ksqrsid2,l.lmode,l.request,l.ctime,decode(l.lmode,0,0,l.block) from v$_lock l, x$ksuse s, x$ksqrs r where l.saddr=s.addr and concat(USERENV('Instance'),l.raddr)=concat(r.inst_id,r.addr)
select s.inst_id,l.laddr,l.kaddr,s.ksusenum,r.ksqrsidt,r.ksqrsid1, r.ksqrsid2,l.lmode,l.request,l.ctime,decode(l.lmode,0,0,l.block) from v$_lock l, x$ksuse s, x$ksqrs r where l.saddr=s.addr and concat(USERENV('Instance'),l.raddr)=concat(r.inst_id,r.addr) and s.inst_id = USERENV('Instance');
and tested more ... with this sql statement.
SQL> explain plan for select s.inst_id,l.laddr,l.kaddr,s.ksusenum,r.ksqrsidt,r.ksqrsid1, r.ksqrsid2,l.lmode,l.request,l.ctime,decode(l.lmode,0,0,l.block) from v$_lock l, x$ksuse s, x$ksqrs r where l.saddr=s.addr and concat(USERENV('Instance'),l.raddr)=concat(r.inst_id,r.addr) and s.inst_id = USERENV('Instance');How to avoid "MERGE JOIN CARTESIAN", tried to use ORDERED hint - The ORDERED hint instructs Oracle to join tables in the order in which they appear in the FROM clause.
Explained.
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY());
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 554400005
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 156 | 1 (100)| 00:00:04 |
|* 1 | HASH JOIN | | 1 | 156 | 1 (100)| 00:00:04 |
| 2 | VIEW | GV$_LOCK | 10 | 760 | 0 (0)| 00:00:01 |
| 3 | UNION-ALL | | | | | |
|* 4 | FILTER | | | | | |
| 5 | VIEW | GV$_LOCK1 | 2 | 152 | 0 (0)| 00:00:01 |
| 6 | UNION-ALL | | | | | |
|* 7 | FIXED TABLE FULL| X$KDNSSF | 1 | 102 | 0 (0)| 00:00:01 |
|* 8 | FIXED TABLE FULL| X$KSQEQ | 1 | 102 | 0 (0)| 00:00:01 |
|* 9 | FIXED TABLE FULL | X$KTADM | 1 | 102 | 0 (0)| 00:00:01 |
|* 10 | FIXED TABLE FULL | X$KTATRFIL | 1 | 102 | 0 (0)| 00:00:01 |
|* 11 | FIXED TABLE FULL | X$KTATRFSL | 1 | 102 | 0 (0)| 00:00:01 |
|* 12 | FIXED TABLE FULL | X$KTATL | 1 | 102 | 0 (0)| 00:00:01 |
|* 13 | FIXED TABLE FULL | X$KTSTUSC | 1 | 102 | 0 (0)| 00:00:01 |
|* 14 | FIXED TABLE FULL | X$KTSTUSS | 1 | 102 | 0 (0)| 00:00:01 |
|* 15 | FIXED TABLE FULL | X$KTSTUSG | 1 | 102 | 0 (0)| 00:00:01 |
|* 16 | FIXED TABLE FULL | X$KTCXB | 1 | 102 | 0 (0)| 00:00:01 |
| 17 | MERGE JOIN CARTESIAN | | 100 | 8000 | 0 (0)| 00:00:01 |
|* 18 | FIXED TABLE FULL | X$KSUSE | 1 | 32 | 0 (0)| 00:00:01 |
| 19 | BUFFER SORT | | 100 | 4800 | 0 (0)| 00:00:01 |
| 20 | FIXED TABLE FULL | X$KSQRS | 100 | 4800 | 0 (0)| 00:00:01 |
-------------------------------------------------------------------------------------
When you omit the
ORDERED
hint from a SQL statement requiring a join, the optimizer chooses the order in which to join the tables. You might want to use the ORDERED
hint to specify a join order if you know something that the optimizer does not know about the number of rows selected from each table. Such information lets you choose an inner and outer table better than the optimizer could.
SQL> explain plan for select /*+ ordered */ s.inst_id,l.laddr,l.kaddr,s.ksusenum,r.ksqrsidt,r.ksqrsid1, r.ksqrsid2,l.lmode,l.request,l.ctime,decode(l.lmode,0,0,l.block) from v$_lock l, x$ksuse s, x$ksqrs r where l.saddr=s.addr and concat(USERENV('Instance'),l.raddr)=concat(r.inst_id,r.addr) and s.inst_id = USERENV('Instance');Good!!! joining changed!!! Test more...
Explained.
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY());
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 3524752130
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 156 | 1 (100)| 00:00:07 |
|* 1 | HASH JOIN | | 1 | 156 | 1 (100)| 00:00:07 |
|* 2 | HASH JOIN | | 1 | 108 | 1 (100)| 00:00:04 |
| 3 | VIEW | GV$_LOCK | 10 | 760 | 0 (0)| 00:00:01 |
| 4 | UNION-ALL | | | | | |
|* 5 | FILTER | | | | | |
| 6 | VIEW | GV$_LOCK1 | 2 | 152 | 0 (0)| 00:00:01 |
| 7 | UNION-ALL | | | | | |
|* 8 | FIXED TABLE FULL| X$KDNSSF | 1 | 102 | 0 (0)| 00:00:01 |
|* 9 | FIXED TABLE FULL| X$KSQEQ | 1 | 102 | 0 (0)| 00:00:01 |
|* 10 | FIXED TABLE FULL | X$KTADM | 1 | 102 | 0 (0)| 00:00:01 |
|* 11 | FIXED TABLE FULL | X$KTATRFIL | 1 | 102 | 0 (0)| 00:00:01 |
|* 12 | FIXED TABLE FULL | X$KTATRFSL | 1 | 102 | 0 (0)| 00:00:01 |
|* 13 | FIXED TABLE FULL | X$KTATL | 1 | 102 | 0 (0)| 00:00:01 |
|* 14 | FIXED TABLE FULL | X$KTSTUSC | 1 | 102 | 0 (0)| 00:00:01 |
|* 15 | FIXED TABLE FULL | X$KTSTUSS | 1 | 102 | 0 (0)| 00:00:01 |
|* 16 | FIXED TABLE FULL | X$KTSTUSG | 1 | 102 | 0 (0)| 00:00:01 |
|* 17 | FIXED TABLE FULL | X$KTCXB | 1 | 102 | 0 (0)| 00:00:01 |
|* 18 | FIXED TABLE FULL | X$KSUSE | 1 | 32 | 0 (0)| 00:00:01 |
| 19 | FIXED TABLE FULL | X$KSQRS | 100 | 4800 | 0 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
SQL> select /*+ ordered */ s.inst_id,l.laddr,l.kaddr,s.ksusenum,r.ksqrsidt,r.ksqrsid1, r.ksqrsid2,l.lmode,l.request,l.ctime,decode(l.lmode,0,0,l.block) from v$_lock l, x$ksuse s, x$ksqrs r where l.saddr=s.addr and concat(USERENV('Instance'),l.raddr)=concat(r.inst_id,r.addr) and s.inst_id = USERENV('Instance');It's faster than....
.
.
.
807 rows selected.
Elapsed: 00:00:00.09
I posted about 'SQL*Net message from client' wrong.... because "MERGE JOIN CARTESIAN" made excessive response time. So, I use : select /*+ ordered */ * from v$lock !!!
select /*+ ordered */ INST_ID, SID, TYPE, ID1, ID2, LMODE, REQUEST, CTIME, BLOCK from gv$lock where (ID1,ID2,TYPE) in (select ID1,ID2,TYPE from gv$lock where request>0) ORDER BY id1, request;This may work for me... but not someone. But I learned "Check More EXPLAIN PLAN!!!, don't just say it's slowly".
Related Post:
Excessive waited 'SQL*Net message from client' - when query V$LOCK
Wednesday, July 20, 2011
Just CREATE TUNING TASK with SQL_ID
This is nothing new, I just traced some session in database and needed to create Tuning Task from SQL_ID. I checked SQL_ID from V$SQLSTATS:
select sql_id, sql_text from V$SQLSTATS;then used SQL_ID with DBMS_SQLTUNE.CREATE_TUNING_TASK
SET SERVEROUTPUT ONthen used DBMS_SQLTUNE.EXECUTE_TUNING_TASK
declare
stmt_task VARCHAR2(100);
begin
stmt_task := DBMS_SQLTUNE.CREATE_TUNING_TASK(sql_id => '0pqarh6218xjx');
DBMS_OUTPUT.put_line('task_id: ' || stmt_task );
end;
/
task_id: TASK_15485
EXEC DBMS_SQLTUNE.EXECUTE_TUNING_TASK(task_name => 'TASK_15485');while using DBMS_SQLTUNE.EXECUTE_TUNING_TASK ... can check status in DBA_ADVISOR_LOG view,
SELECT task_name, status FROM DBA_ADVISOR_LOG;when status=COMPLETED ... and then got recommendations!!!
SET LINESIZE 200
SELECT DBMS_SQLTUNE. REPORT_TUNING_TASK('TASK_15485') AS recommendations FROM dual;
Tuesday, June 28, 2011
just test optimizer_index_cost_adj
How to use optimizer_index_cost_adj for controlling the Behavior of the Optimizer?
This is something what simples for someone and you can see many articles on internet, in books or etc. However, You should learn, test, and ... by yourself. That is useful for learning.
A optimizer_index_cost_adj(default 100 percent) is parameter what defines the percentage of the cost of an index.
optimizer_index_cost_adj = The range of values is 1 to 10000, which means that indexes are evaluated as an access path (index). If you set it much lower than 100 (Execution Plan has a chance to use INDEX), Really?
This is example for testing. However, this parameter is good idea for someone who spend much time with query query and query.
This is something what simples for someone and you can see many articles on internet, in books or etc. However, You should learn, test, and ... by yourself. That is useful for learning.
A optimizer_index_cost_adj(default 100 percent) is parameter what defines the percentage of the cost of an index.
SQL> select product_nameThe result shows one row, and Execution plan uses INDEX. but After changed SQL (quantity = 48) to (quantity > 1)
from order_items o, product_information p
where o.unit_price = 15 and quantity = 48
and p.product_id = o.product_id;
PRODUCT_NAME QUANTITY
-------------------------------------------------- ----------
Screws <B.28.S> 48
Execution Plan
----------------------------------------------------------
Plan hash value: 1255158658
-------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 32 | 3 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | | | | |
| 2 | NESTED LOOPS | | 1 | 32 | 3 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL | ORDER_ITEMS | 1 | 12 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | PRODUCT_INFORMATION_PK | 1 | | 0 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID| PRODUCT_INFORMATION | 1 | 20 | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------------
SQL> select product_name, quantityA Execution Plan shows "TABLE ACCESS FULL", How to control the behavior of the Optimizer? If, I would like to use INDEX.
from order_items o, product_information p
where o.unit_price = 15 and quantity > 1
and p.product_id = o.product_id;
PRODUCT_NAME QUANTITY
-------------------------------------------------- ----------
Screws <B.28.S> 48
Screws <B.28.S> 24
Screws <B.28.S> 176
Screws <B.28.S> 39
Screws <B.28.S> 82
Screws <B.28.S> 129
Screws <B.28.S> 17
Screws <B.28.S> 30
Screws <B.28.S> 21
Screws <B.28.S> 12
Screws <B.28.S> 31
Screws <B.28.S> 93
Screws <B.28.S> 97
13 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1553478007
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4 | 128 | 6 (17)| 00:00:01 |
|* 1 | HASH JOIN | | 4 | 128 | 6 (17)| 00:00:01 |
|* 2 | TABLE ACCESS FULL| ORDER_ITEMS | 4 | 48 | 2 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| PRODUCT_INFORMATION | 288 | 5760 | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------------------
optimizer_index_cost_adj = The range of values is 1 to 10000, which means that indexes are evaluated as an access path (index). If you set it much lower than 100 (Execution Plan has a chance to use INDEX), Really?
SQL> show parameter optimizer_index_cost_adj*** optimizer_index_cost_adj=50 - that mean index access path look half as expensive as normal ***
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
optimizer_index_cost_adj integer 100
SQL> alter session set optimizer_index_cost_adj=50;
Session altered.
SQL> select product_name, quantity
from order_items o, product_information p
where o.unit_price = 15 and quantity > 1
and p.product_id = o.product_id;
Execution Plan
----------------------------------------------------------
Plan hash value: 1255158658
-------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4 | 128 | 4 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | | | | |
| 2 | NESTED LOOPS | | 4 | 128 | 4 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL | ORDER_ITEMS | 4 | 48 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | PRODUCT_INFORMATION_PK | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID| PRODUCT_INFORMATION | 1 | 20 | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------------
This is example for testing. However, this parameter is good idea for someone who spend much time with query query and query.
Friday, June 24, 2011
Test: Pending Statistics
I read from Oracle Document and interest about Pending Statistics. When Objects are gathered, the statistics will be automatically published. Check!!!
You can change PUBLISH at either the schema or the table level. This example, I use SH.SALES table. *** Before test, I delete statistics on this table.
When Execution Plan shows good plan and want to publish (use dbms_stats.publish_pending_stats)... and if want to delete pending statistics(use dbms_stats.delete_pending_stats)
SQL> SELECT DBMS_STATS.GET_PREFS('PUBLISH') PUBLISH FROM DUAL;Result = TRUE or FALSE. TRUE = the statistics will be published as and when they are gathered, FALSE = the statistics will be kept pending.
PUBLISH
----------
TRUE
You can change PUBLISH at either the schema or the table level. This example, I use SH.SALES table. *** Before test, I delete statistics on this table.
SQL> select * from sales where PROD_ID=12;After I deleted statistics. Execution Plan - "TABLE ACCESS FULL". Then set preference (PUBLISH=false) for SALES table. *** not publish after it is gathered.
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 511273406
---------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
---------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 352 | 10208 | 94 (0)| 00:00:01 | | |
| 1 | PARTITION RANGE ALL | | 352 | 10208 | 94 (0)| 00:00:01 | 1 | 28 |
| 2 | TABLE ACCESS BY LOCAL INDEX ROWID| SALES | 352 | 10208 | 94 (0)| 00:00:01 | 1 | 28 |
| 3 | BITMAP CONVERSION TO ROWIDS | | | | | | | |
|* 4 | BITMAP INDEX SINGLE VALUE | SALES_PROD_BIX | | | | | 1 | 28 |
---------------------------------------------------------------------------------------------------------------------
SQL> exec dbms_stats.DELETE_TABLE_STATS('SH','SALES');
PL/SQL procedure successfully completed.
SQL> select * from sales where PROD_ID=12;
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 1550251865
---------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
---------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 87 | 351 (1)| 00:00:01 | | |
| 1 | PARTITION RANGE ALL| | 1 | 87 | 351 (1)| 00:00:01 | 1 | 28 |
|* 2 | TABLE ACCESS FULL | SALES | 1 | 87 | 351 (1)| 00:00:01 | 1 | 28 |
---------------------------------------------------------------------------------------------
SQL> exec dbms_stats.set_table_prefs('SH','SALES','PUBLISH','false');Gather SALES table and test...
PL/SQL procedure successfully completed.
SQL> exec dbms_stats.gather_table_stats('SH','SALES');Still "TABLE ACCESS FULL", because not use statistics. However use optimizer_use_pending_statistics=true for using pending statistics.
PL/SQL procedure successfully completed.
SQL> select * from sales where PROD_ID=12;
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 1550251865
---------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
---------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 87 | 351 (1)| 00:00:01 | | |
| 1 | PARTITION RANGE ALL| | 1 | 87 | 351 (1)| 00:00:01 | 1 | 28 |
|* 2 | TABLE ACCESS FULL | SALES | 1 | 87 | 351 (1)| 00:00:01 | 1 | 28 |
---------------------------------------------------------------------------------------------
SQL> alter session set optimizer_use_pending_statistics=true;This shows new Execution Plan, because it used new statistics.
Session altered.
SQL> select * from sales where PROD_ID=12;
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 511273406
---------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
---------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 352 | 10208 | 94 (0)| 00:00:01 | | |
| 1 | PARTITION RANGE ALL | | 352 | 10208 | 94 (0)| 00:00:01 | 1 | 28 |
| 2 | TABLE ACCESS BY LOCAL INDEX ROWID| SALES | 352 | 10208 | 94 (0)| 00:00:01 | 1 | 28 |
| 3 | BITMAP CONVERSION TO ROWIDS | | | | | | | |
|* 4 | BITMAP INDEX SINGLE VALUE | SALES_PROD_BIX | | | | | 1 | 28 |
---------------------------------------------------------------------------------------------------------------------
When Execution Plan shows good plan and want to publish (use dbms_stats.publish_pending_stats)... and if want to delete pending statistics(use dbms_stats.delete_pending_stats)
SQL> exec dbms_stats.publish_pending_stats('SH','SALES');Good!!! use Pending Statistics for test Execution Plan before Publish (statistics).
PL/SQL procedure successfully completed.
SQL> exec dbms_stats.delete_pending_stats('SH','SALES');
PL/SQL procedure successfully completed.
Friday, February 18, 2011
What is a session doing in DB?
Please help to check my session!!! Maybe, We often hear this question. If we have EM, this is easy to check and investigate.
But... If we can only use sql command, what is your idea or step?
However, someone asked me this question and only knew username, what I should start to check? I...
checked blocking (Link): *** this sql can not use on version < 10G ***
then disabled trace on that session:
But... If we can only use sql command, what is your idea or step?
However, someone asked me this question and only knew username, what I should start to check? I...
checked blocking (Link): *** this sql can not use on version < 10G ***
select 'Session ID=' ||SID ||'(Inst '||INST_ID||') IS BLOCKED BY Session ID='|| BLOCKING_SESSION || '(Inst '||BLOCKING_INSTANCE||')' from gv$session where BLOCKING_SESSION is not null;... OK!!! no blocking, time to use username to find out more about that session, investigation and answer user -)
SQL> select sid, serial#, username, program, event, p1, status, sql_id from v$session where username='DEMO';That showed SID, EVENT, STATUS and SQL_ID, then checked about SQL statement.
SID SERIAL# USERNAME PROGRAM EVENT P1 STATUS SQL_ID
---------- ---------- -------- ----------------------------------- ------------------------------ -- -------- -------------
45 43 DEMO sqlplus@linuxclient (TNS V1-V3) direct path read 4 ACTIVE ckg31y8rg6psa
SQL> select sql_text, disk_reads, buffer_gets, cpu_time from v$sqlstats where sql_id='ckg31y8rg6psa';Checked Xplan:
SQL_TEXT DISK_READS BUFFER_GETS CPU_TIME
---------------------------------------------------------------------- ---------- ----------- ----------
select id, sum (id + 10000)/1 from tb_test where id >1000 group by id 23530 23312 95802415
SQL> select * from table(dbms_xplan.display_cursor('ckg31y8rg6psa','','typical'));Enabled trace on that session:
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
SQL_ID ckg31y8rg6psa, child number 0
-------------------------------------
select id, sum (id + 10000)/1 from tb_test where id >1000 group by id
Plan hash value: 2744048799
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 856 (100)| |
| 1 | HASH GROUP BY | | 1179K| 14M| 856 (7)| 00:00:11 |
|* 2 | TABLE ACCESS FULL| TB_TEST | 1179K| 14M| 811 (2)| 00:00:10 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("ID">1000)
SQL> exec dbms_monitor.session_trace_enable(45,43);Checked from trace file, what that session was doing.
PL/SQL procedure successfully completed.
SQL> select sql_trace from v$session where sid=45 and serial# =43;
SQL_TRACE
--------
ENABLED
SQL> select p.spid, p.tracefile from v$session s, v$process p where s.paddr = p.addr and s.sid=45;
SPID TRACEFILE
------------------------ -------------------------------------------------------
970 /oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_970.trc
$ tail -f /oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_970.trcOr used "tkprof" to make trace report file.
WAIT #5417428: nam='direct path read' ela= 120 file number=4 first dba=617 block cnt=15 obj#=81188 tim=1298022456269076
$ tkprof /oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_970.trc out.prf sys=noExample:
SQL ID: ckg31y8rg6psa Plan Hash: 2744048799What is the answer? - that session was waiting at 'direct path read' event on file_id=4:
select id, sum (id + 10000)/1
from
tb_test where id >1000 group by id
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.05 0.07 398 80 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 68875 25.20 26.06 5384 5709 0 1033097
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 68879 25.25 26.13 5782 5789 0 1033097
SQL> select tablespace_name from dba_data_files where file_id=4;and SQL in that session was doing "TABLE ACCESS FULL" and fetched many rows.
TABLESPACE_NAME
------------------------------
USERS
then disabled trace on that session:
SQL> exec dbms_monitor.session_trace_disable(45,43);How about your idea? wish to know...
PL/SQL procedure successfully completed.
SQL> select sql_trace from v$session where sid=45 and serial# =43;
SQL_TRACE
--------
DISABLED
Tuesday, November 30, 2010
SQL and Relational Theory Master Class (How to Write Accurate SQL Code) by C.J. Date
What is SQL? SQL is referred to as Structured Query Language, is a database computer language designed for managing data in relational database management systems (RDBMS), and originally based upon relational algebra. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.
SQL is ubiquitous, but it's also complicated, difficult, and error prone.
"C.J. Date's SQL and Relational Theory Master Class" How to Write Accurate SQL Code by C. J. Date is the excellent video(16 hours), We will learn the world's best-known relational advocate and how to write SQL code that's logically correct, how to avoid various SQL traps and pitfalls, and, more generally, how to use SQL as if it were a true relational language.
Table of Contents
- Setting the Scene Part 1 - 2
- Types and domains Part 1 - 3
- Tuples and Relations, Rows and Tables Part 1 - 2
- No Duplicates, No Nulls Part 1 - 2
- Base Relvars, Base Tables Part 1 - 3
- SQL and Relational Algebra I: The Original Operators Part 1 - 2
- SQL and Relational Algebra II: Additional Operators Part 1 - 2
- SQL and Constraints Part 1 - 2
- SQL and Views Part 1 - 2
- SQL and logic I: Relational Calculus Part 1 - 4
- SQL and Logic II: Using Logic to Write SQL Code Part 1 - 2
- The Relational Model
- Database Design Theory Part 1 - 2
When... We need to write accurate SQL Code, I recommend this Videos (C.J. Date's SQL and Relational Theory Master Class: How to Write Accurate SQL Code) and (SQL and Relational Theory book). This will helpful our thought about SQL.
We will start about SQL relationally theory, learn the difference between relation values and relation variables, a detailed examination of the original relational operators (join, etc.) and logic in the relational model.
Some Sample:
- Types and domains Part 1 - 3
We will learn relations and basic understanding of elementary type theory is a prerequisite to understanding everything that follows.
- Tuples and Relations, Rows and Tables Part 1 - 2
We will learn tuples and relations (rows and tables, in SQL terms) the fundamental building blocks of the relational model.
- No Duplicates, No Nulls Part 1 - 2
We will learn duplicates and nulls, they are two of the most obvious SQL departures from the relational model. This session explains in detail some of the problems those departures cause, and why duplicates and nulls should be avoided.
- The Relational Model
This session is the first of three appendixes to the main body of the seminar. Among other things, it offers a precise definition of the relational model, and it offers strong evidence to support the contention that the relational model will stand the test of time.
- Database Design Theory Part 1 - 2
We will learn logical design theory... Essentially normalization and denormalization.
...more
Christopher J. Date attended High Wycombe Royal Grammar School (U.K.) from 1951 to 1958 and received his B.A. in Mathematics from Cambridge University (U.K.) in 1962. He entered the computer business as a mathematical programmer at Leo Computers Ltd. (London), where he quickly moved into education and training. In 1966, he earned his Master's degree at Cambridge, and, in 1967, he joined IBM Hursley (U.K) as a programming instructor. Between 1969 and 1974, he was a principal instructor in IBM's European education program.
SQL is ubiquitous, but it's also complicated, difficult, and error prone.

Table of Contents
- Setting the Scene Part 1 - 2
- Types and domains Part 1 - 3
- Tuples and Relations, Rows and Tables Part 1 - 2
- No Duplicates, No Nulls Part 1 - 2
- Base Relvars, Base Tables Part 1 - 3
- SQL and Relational Algebra I: The Original Operators Part 1 - 2
- SQL and Relational Algebra II: Additional Operators Part 1 - 2
- SQL and Constraints Part 1 - 2
- SQL and Views Part 1 - 2
- SQL and logic I: Relational Calculus Part 1 - 4
- SQL and Logic II: Using Logic to Write SQL Code Part 1 - 2
- The Relational Model
- Database Design Theory Part 1 - 2
When... We need to write accurate SQL Code, I recommend this Videos (C.J. Date's SQL and Relational Theory Master Class: How to Write Accurate SQL Code) and (SQL and Relational Theory book). This will helpful our thought about SQL.
We will start about SQL relationally theory, learn the difference between relation values and relation variables, a detailed examination of the original relational operators (join, etc.) and logic in the relational model.
Some Sample:
- Types and domains Part 1 - 3
We will learn relations and basic understanding of elementary type theory is a prerequisite to understanding everything that follows.
- Tuples and Relations, Rows and Tables Part 1 - 2
We will learn tuples and relations (rows and tables, in SQL terms) the fundamental building blocks of the relational model.
- No Duplicates, No Nulls Part 1 - 2
We will learn duplicates and nulls, they are two of the most obvious SQL departures from the relational model. This session explains in detail some of the problems those departures cause, and why duplicates and nulls should be avoided.
- The Relational Model
This session is the first of three appendixes to the main body of the seminar. Among other things, it offers a precise definition of the relational model, and it offers strong evidence to support the contention that the relational model will stand the test of time.
- Database Design Theory Part 1 - 2
We will learn logical design theory... Essentially normalization and denormalization.
...more
Christopher J. Date attended High Wycombe Royal Grammar School (U.K.) from 1951 to 1958 and received his B.A. in Mathematics from Cambridge University (U.K.) in 1962. He entered the computer business as a mathematical programmer at Leo Computers Ltd. (London), where he quickly moved into education and training. In 1966, he earned his Master's degree at Cambridge, and, in 1967, he joined IBM Hursley (U.K) as a programming instructor. Between 1969 and 1974, he was a principal instructor in IBM's European education program.
Wednesday, October 14, 2009
Oracle SQL Developer 2.1 Book
Oracle SQL Developer is a graphical tool for database development and free. We can browse database objects, run SQL Statements, SQL scripts and edit/debug PL/SQL Statements.
Oracle SQL Developer 2.1 Early Adopter now available (min JDK 1.6 update11) - 24th September '09
We can check Oracle SQL Developer 2.1: New Features and Feature List.

After I reviewed this ebook. This book is helpful to start Oracle SQL Developer 2.1 step by step.
We can use this book to be reference/manual when we use Oracle SQL Developer.
Reference:
- SQL Developer on OTN
Oracle SQL Developer 2.1 Early Adopter now available (min JDK 1.6 update11) - 24th September '09
We can check Oracle SQL Developer 2.1: New Features and Feature List.

I mention a book titled "Oracle SQL Developer 2.1" written by Sue Harper (Sue's Blog). Sue wrote an excellent Oracle SQL Developer's guide. "Oracle SQL Developer 2.1" covers SQL Developer fundamentals as well more intermediate and advanced topics, this book uses in-depth explanation and detailed examples to help you get the most out of Oracle SQL Developer.
What we will learn from this book:
- Build complex queries based on a number of tables using visual Query Builder
- Assess the health of your database, data structure of your application, and data in that application with built-in as well as user-defined reports
- Create, compile, and debug PL/SQL code and explore available features to facilitate writing PL/SQL code
- Integrate your SQL Developer with open source version control systems CVS and Subversion, which allow checking out of files from a repository, editing, and checking them back in
- Enter and execute your SQL, PL/SQL, and SQL*Plus statements with the SQL Worksheet interface
- Produce easily replicable scripts that copy and move data from one database instance to another, or from one schema to another
- Create advanced database connections using a variety of connection and authentication types available for Oracle as well as non-Oracle databases
- Create, review, and update database schema designs with SQL Developer Data Modeler
- Augment your environment with features that are specific to your needs by extending your SQL Developer with XML structured user-defined extensions
- Monitor and manage your Application Express applications by integrating with SQL Developer
- Set up an easy and quick migration environment for your database schema by using the migration repository
- Browse and review non-Oracle databases, before using the migration environment to migrate and consolidate databases on the Oracle platform
After I reviewed this ebook. This book is helpful to start Oracle SQL Developer 2.1 step by step.
We can use this book to be reference/manual when we use Oracle SQL Developer.
Reference:
- SQL Developer on OTN
- Exchange
Friday, July 24, 2009
Dynamic SQL: cursor: pin S wait on X
I worked with load testing on oracle database with OLTP (query many times in the same sql statements) and found high waited events on cursor: pin S wait on X and cursor: mutex X
And then i investigated PL/SQL code and found dynamic sql, so i made test (wrote pl/sql with dynamic sql) and check waited events.
Example Test
Dynamice SQL:
create or replace function build_query_stmt (obj_id IN number) return varchar2
is
v_stmt varchar2(2000);
begin
v_stmt := 'select count(1) c from TMP01 ';
v_stmt := v_stmt || ' where object_id=' || obj_id ;
return v_stmt;
end;
/
create or replace procedure A (obj_id IN number)
is
type t_refcur is REF CURSOR;
crs t_refcur;
v_stmt varchar2(2000);
v_c number;
begin
v_stmt := build_query_stmt(obj_id);
open crs for v_stmt;
< < a_loop > >
LOOP
begin
fetch crs into v_c;
exit a_loop when crs%NOTFOUND;
dbms_output.put_line(v_c);
end;
end loop;
close crs;
end;
/
Test many times: exec a(:p);
Check:
create or replace procedure B (obj_id IN number)
is
v_c number;
begin
execute immediate 'select count(*) from TMP01 where object_id = :p1' into v_c using obj_id ;
dbms_output.put_line(v_c);
end;
/
Test many times: exec b(:p);
Check:
cursor: pin S wait on X:read ideas from Tanel Poder and Alex Fatkulin
A session waits on this event when requesting a mutex for sharable operations related to pins(such as executing a cursor)), but the mutex cannot be granted because it is being held exclusively by another session (which is most likely parsing the cursor).
And then i investigated PL/SQL code and found dynamic sql, so i made test (wrote pl/sql with dynamic sql) and check waited events.
Example Test
Dynamice SQL:
create or replace function build_query_stmt (obj_id IN number) return varchar2
is
v_stmt varchar2(2000);
begin
v_stmt := 'select count(1) c from TMP01 ';
v_stmt := v_stmt || ' where object_id=' || obj_id ;
return v_stmt;
end;
/
create or replace procedure A (obj_id IN number)
is
type t_refcur is REF CURSOR;
crs t_refcur;
v_stmt varchar2(2000);
v_c number;
begin
v_stmt := build_query_stmt(obj_id);
open crs for v_stmt;
< < a_loop > >
LOOP
begin
fetch crs into v_c;
exit a_loop when crs%NOTFOUND;
dbms_output.put_line(v_c);
end;
end loop;
close crs;
end;
/
Test many times: exec a(:p);
Check:
Top 5 Timed Events Avg %TotalStatic SQL:
~~~~~~~~~~~~~~~~~~ wait Call
Event Waits Time (s) (ms) Time Wait Class
------------------------------ ------------ ----------- ------ ------ ----------
cursor: pin S wait on X 19,679 216 11 49.8 Concurrenc
CPU time 183 42.1
kksfbc child completion 445 22 50 5.1 Other
cursor: mutex S 1,017 1 1 0.2 Concurrenc
latch: library cache 1,886 1 0 0.2 Concurrenc
create or replace procedure B (obj_id IN number)
is
v_c number;
begin
execute immediate 'select count(*) from TMP01 where object_id = :p1' into v_c using obj_id ;
dbms_output.put_line(v_c);
end;
/
Test many times: exec b(:p);
Check:
Top 5 Timed Events Avg %TotalDynamic SQL use waited time event: "cursor: pin S wait on X" higher Static SQL, so be careful to use it.
~~~~~~~~~~~~~~~~~~ wait Call
Event Waits Time (s) (ms) Time Wait Class
------------------------------ ------------ ----------- ------ ------ ----------
CPU time 80 55.7
cursor: pin S wait on X 4,364 49 11 33.6 Concurrenc
kksfbc child completion 234 12 50 8.2 Other
latch: library cache 2,556 1 1 1.0 Concurrenc
latch: shared pool 1,971 1 0 0.4 Concurrenc
Wednesday, March 25, 2009
Just ... Forcing a Specific Table Join Method
Oracle database, we can use hints to force a specific join method.
USE_NL = NESTED LOOPS join
USE_MERGE = SORT-MERGE join
USE_HASH = HASH join
Before use each of hints with table join, we should know about join method.
On 10g Performance Tuning Tips & Tech book told about a quick view of the primary join type.
I think that's help us determine hints before we will force a specific table join.
Example to use hints to force a specific table join method:
>>> Create Tables
SQL> create table A as select * from dba_objects;
Table created.
SQL> create table B as select * from user_objects;
Table created.
>>> Create Index
Begin Testing: Use hints to force a specific table join method.
pga_aggregate_target : improve performance of all sorts.
db_file_multiblock_read_count : good for full table scans.
USE_NL = NESTED LOOPS join
USE_MERGE = SORT-MERGE join
USE_HASH = HASH join
Before use each of hints with table join, we should know about join method.
On 10g Performance Tuning Tips & Tech book told about a quick view of the primary join type.
Category | NESTED LOOPS join | SORT-MERGE join | HASH join |
Hint | USE_NL | USE_MERGE | USE_HASH |
Resource Concerns | CPU, disk I/O. | Memory, temporary segments. | Memory, temporary segments. |
Features | Efficient with highly selective indexes and restrictive searches. Used to return the first row of a result quickly. | Better than NESTED LOOPS when an index is missing or the search criteria are not very selective. Can work with limited memory. | Better than NESTED LOOPS when an index is missing or the search criteria are not very selective. It is usually faster than a SORT-MERGE. |
Drawbacks | Very inefficient when indexes are missing or if the index criteria are not limiting. | Requires a sort on both tables. It is built for best optimal throughput and does not return the first row until all row are found. | Can require a large amount of memory for the hash table to be built. Does not return the first rows quickly. Can be extremely slow if it must do the operation on disk. |
I think that's help us determine hints before we will force a specific table join.
Example to use hints to force a specific table join method:
>>> Create Tables
SQL> create table A as select * from dba_objects;
Table created.
SQL> create table B as select * from user_objects;
Table created.
>>> Create Index
SQL> create index A_I01 on A(object_id,object_name);
Index created.
Begin Testing: Use hints to force a specific table join method.
when use table join, we should determine some initialization parameters to join + performance ;)SQL> set autot trace explainSQL> select /*+ ordered */ * from A , B where A.object_id=B.object_id ;Execution Plan----------------------------------------------------------Plan hash value: 652036164-----------------------------------------------------------------------------------Id Operation Name Rows Bytes TempSpc Cost (%CPU) Time-----------------------------------------------------------------------------------0 SELECT STATEMENT 456 150K 475 (1) 00:00:06* 1 HASH JOIN 456 150K 6448K 475 (1) 00:00:062 TABLE ACCESS FULL A 34930 6037K 154 (1) 00:00:023 TABLE ACCESS FULL B 456 72960 3 (0) 00:00:01-----------------------------------------------------------------------------------SQL> select /*+ use_nl (A B) */ * from A , B where A.object_id=B.object_id ;Execution Plan----------------------------------------------------------Plan hash value: 4149619786-------------------------------------------------------------------------------------Id Operation Name Rows Bytes Cost (%CPU) Time-------------------------------------------------------------------------------------0 SELECT STATEMENT 456 150K 916 (1) 00:00:111 TABLE ACCESS BY INDEX ROWID A 1 177 2 (0) 00:00:012 NESTED LOOPS 456 150K 916 (1) 00:00:113 TABLE ACCESS FULL B 456 72960 3 (0) 00:00:01* 4 INDEX RANGE SCAN A_I01 1 1 (0) 00:00:01-------------------------------------------------------------------------------------SQL> select /*+ use_merge (A B) */ * from A , B where A.object_id=B.object_id ;Execution Plan----------------------------------------------------------Plan hash value: 3028542103------------------------------------------------------------------------------------Id Operation Name Rows Bytes TempSpc Cost (%CPU) Time------------------------------------------------------------------------------------0 SELECT STATEMENT 456 150K 1515 (1) 00:00:191 MERGE JOIN 456 150K 1515 (1) 00:00:192 SORT JOIN 456 72960 4 (25) 00:00:013 TABLE ACCESS FULL B 456 72960 3 (0) 00:00:01* 4 SORT JOIN 34930 6037K 14M 1511 (1) 00:00:195 TABLE ACCESS FULL A 34930 6037K 154 (1) 00:00:02------------------------------------------------------------------------------------SQL> select /*+ use_hash (A B) */ * from A , B where A.object_id=B.object_id ;Execution Plan----------------------------------------------------------Plan hash value: 4090908061---------------------------------------------------------------------------Id Operation Name Rows Bytes Cost (%CPU) Time---------------------------------------------------------------------------0 SELECT STATEMENT 456 150K 158 (2) 00:00:02* 1 HASH JOIN 456 150K 158 (2) 00:00:022 TABLE ACCESS FULL B 456 72960 3 (0) 00:00:013 TABLE ACCESS FULL A 34930 6037K 154 (1) 00:00:02---------------------------------------------------------------------------
pga_aggregate_target : improve performance of all sorts.
db_file_multiblock_read_count : good for full table scans.
Thursday, February 05, 2009
Oracle Insert Faster, How?
When I would like to Insert Faster on Oracle database.
Using High I/O, High CPU and High Memory, they're a great to do.
Anyway What I should to do on Database, (SQL) ... on Table... on Index ???
About my issue...
I have many clients and many sessions, they connected and inserted data on (TABLE) Oracle in the same time.
*** Not Use CTAS***
In My Idea I use bigger block size ,nolgging, no archivelog, no indexing (Actually I use 3 indexes) and Increase Buffer Cache.
I can't not use "APPEND", Becasue In the same session i insert only one row.
INSERT INTO TABLE_NAME VALUES(...);
Example:
beginfor x in 1 ..100loopinsert into t01 values(x, 100);commit;end loop;end;/Elapsed: 00:00:00.16beginfor x in 1 ..100loopinsert /*+ append */ into t01 values(x, 100);commit;end loop;end;/Elapsed: 00:00:01.15
Enough? I thought No! about idea... So, I'd like to know another idea else, So I posted to ask on Oracle Community.
Thank You many people to post their suggestion.
I would like to share their idea to other. Perhaps that can help... other
Gerald Venzl suggests:
1) Bulking (if you want to make it fast, do bulking!) which reduces commits and commit time
- In the same session i insert only one row, that can not...help
2) Enough ITL on the block (INITRANS)
3) Depending on the size of a row: Blocksize, PCTFREE
4) No Indexing
5) No integrity checks (Foreign keys, not null constraints)
6) Buffer cache (if it's to small you'll early end up with I/O)
7) And Partitioning
Gerald's Suggestion great.
Filipe Martins 's Idea helpful with his real experience, he suggests good idea from his experience to create table with partitioning table.
He told i should create table with range and list ...
Assume, I have clients (C1, C2, C3, ...,Cn) to connect and insert data, So create table with range partition on (Client)
So:
On C1 clinet .. insert into table_name partition (Partition_C1) values() ;
On C2 clinet .. insert into table_name partition (Partition_C2) values() ;
.
.
On Cn clinet .. insert into table_name partition (Partition_Cn) values() ;
good!
TongucY help me what i should to do before... anyway , that's make SQL TRACE event 10046 level 8. and then use tkprof to check.
Arie told i should to know... It's inserted from other table or one row...
Finally, Joe Goodman suggests:
1. If Inserts are comming from many processes then contention might occur due to
1.1. Buffer Busy wait to to contention for update access to same table block. This
may be checked in v$segment_statistics. If so then smaller block sizes or
higher PCTFREE may help reduce number of rows per block but using ASSM
will help as well.
- About smaller block size. I'n not sure about this idea, Becasue data is inserted ..., no update
1.2 If same process is inserting many rows using CTAS, or insert into... select
from then parallel execution should speed the process along.
- In the same session i insert only one row, that can not...help
1.3 If indexes exist on the table then the problem may be cause by Buffer Busy
Wait on the right hand block of the index also visible in v$segment_statistics.
If so then one may either use Reverse Key Indexes (if the index is not needed for
range scan access paths) or use Hash partitioned Global index (if you have a
license for partitioning) or possibly both as these reduce contention on the right
had index block.
Many Ideas, I'm sure to improve performance insert faster... Thank You!
About my issue I'll start with new table:
- Partitioning Table, range ... perhaps list
- increase INITRANS...
- reduce number of Indexes
- try to no constraint
- increase buffer cache and check about variable on sql statement help reduce library cache size
- bigger block size ... actually not sure, I have to test before.
- Perhaps use nologging (or no archivelog)
- finally, use SQL TRACE 10046 to trace about waited and ... tune!
...
Thursday, January 22, 2009
get Cluster Waited Event from V$SQLSTATS
Nothing this day, I sat around and wrote script to check sql statement used much time on Cluster Waited Event.
Actually that could query cluster_wait_time on v$sqlstats as well.
On three Views could help get another else..., Example: BUFFER_GETS, DISK_READS, DIRECT_WRITES ...blah blah
Which view should we query?
V$SQLSTATS view is queried faster...
select sql_text, cluster_wait_time from v$sql where cluster_wait_time > 50000000 order by 2;Elapsed: 00:00:00.40
select sql_text, cluster_wait_time from v$sqlarea where cluster_wait_time > 50000000 order by 2;Elapsed: 00:00:00.46
select sql_text, cluster_wait_time from v$sqlstats where cluster_wait_time > 50000000 order by 2;Elapsed: 00:00:00.05
Why?...
Oracle database Version 10.2.0.2 and later, a SELECT from the V$SQLSTATS view is protected by mutexes.
select sql_text, cluster_wait_time, sharable_mem, buffer_gets, disk_reads from v$sqlstats where cluster_wait_time > 50000000 order by 2
SQL_TEXT CLUSTER_WAIT_TIME SHARABLE_MEM BUFFER_GETS DISK_READS
--------------------------------------------------------------------------------
call "TEST"() 6.8305E+10 11280 658815078 7653630
Friday, January 16, 2009
Oracle 9.2.0.6... get Wrong Results with using Variable
With Oracle 9.2.0.6 on Sparc...
NAME column is varchar2.
Test query...
SQL> select count(*) from TABLE_NAME where NAME = 'TEST';
COUNT(*)
----------
1
Use Variable...
SQL> declare
2 V varchar2(17) := 'TEST';
3 a number;
4 begin
5 dbms_output.put_line('value='||V );
6 select count(*) into a from TABLE_NAME WHERE NAME = V;
7 dbms_output.put_line(a);
8 end;
9 /
value=TEST
10693
This PL/SQL gets wrong result from table...
So, try to new... PL/SQL... Variable using "execute immediate"
SQL> declare
2 V varchar2(17) := 'TEST';
3 a number;
4 begin
5 dbms_output.put_line('value='||V );
6 execute immediate 'select count(*) FROM TABLE_NAME WHERE NAME = :p1' into a using V ;
7 dbms_output.put_line(a);
8 end;
9 /
value=TEST
1
That is Right Result.
Remark:
This case make wrong Data... Because used "COLUMN NAME" to be "VARIABLE NAME" on PL/SQL and ..., It make sql statement like: "where column1 = column2" (see on every VERSIONs). So, That should to avoid using "COLUMN NAME" to be "VARIABLE NAME" on PL/SQL and ... , Anyway If... need to use!..., using "EXECUTE IMMEDIATE" can help!
Thank you Gary MYERS
Wednesday, November 12, 2008
Using quick_tune to generates recommendations
When we need to analyze and generate recommendations for a single SQL statement, that can use dbms_advisor.quick_tune to help:
dbms_advisor.quick_tune(
advisor_name IN VARCHAR2,
task_name IN VARCHAR2,
attr1 IN CLOB := NULL,
attr2 IN VARCHAR2 := NULL,
attr3 IN NUMBER := NULL,
template IN VARCHAR2 := NULL,
implement IN BOOLEAN := FALSE,
description IN VARCHAR2 := NULL);
Example to use dbms_advisor.quick_tune :
- create table for testing.
CREATE TABLE TEMP01 NOLOGGING AS SELECT * FROM ALL_OBJECTS;
ANALYZE TABLE TEMP01 COMPUTE STATISTICS;
A SQL Statement need to analyze : select object_name from temp01 where object_id=1234
- Begin analyze and get recommendation.
desc user_advisor_templates
set linesize 100
col task_name format a40
col description format a50
SELECT task_name, description FROM user_advisor_templates;
TASK_NAME DESCRIPTION
---------------------------------------- -----------------------
SQLACCESS_GENERAL General purpose database template
SQLACCESS_OLTP OLTP database template
SQLACCESS_WAREHOUSE Data Warehouse database template
SQLACCESS_EMTASK Default Enterprise Manager task template
desc user_advisor_journal
SELECT COUNT(*) FROM user_advisor_journal;
COUNT(*)
----------
0
DECLARE
task_name VARCHAR2(30) := 'TEST01';
BEGIN
dbms_advisor.quick_tune(dbms_advisor.sqlaccess_advisor, task_name,
'select object_name from temp01 where object_id=1234');
END;
/
SELECT COUNT(*) FROM user_advisor_journal;
COUNT(*)
----------
19
col task_name format a10
col journal_entry_type format a15
col journal_entry format a65
SELECT task_name, journal_entry_type, journal_entry
FROM user_advisor_journal WHERE task_name = 'TEST01';
TASK_NAME JOURNAL_ENTRY_T JOURNAL_ENTRY
---------- --------------- -----------------------
TEST01 INFORMATION Preparing workload for analysis
TEST01 INFORMATION Filter Summary: Valid username: Unused
TEST01 INFORMATION Filter Summary: Invalid username: Unused
TEST01 INFORMATION Filter Summary: Valid module: Unused
TEST01 INFORMATION Filter Summary: Invalid module: Unused
TEST01 INFORMATION Filter Summary: Valid action: Unused
TEST01 INFORMATION Filter Summary: Invalid action: Unused
TEST01 INFORMATION Filter Summary: Valid SQL String: Unused
TEST01 INFORMATION Filter Summary: Invalid SQL String: Statements discarded: 0
TEST01 INFORMATION Filter Summary: Invalid start time: Unused
TEST01 INFORMATION Filter Summary: Invalid end time: Unused
TEST01 INFORMATION Filter Summary: Invalid table: Unused
TEST01 INFORMATION Filter Summary: Valid table: Unused
TEST01 INFORMATION Filter Summary: Invalid table reference:
Statements discarded: 0
TEST01 INFORMATION Filter Summary: SQL Syntax or Semantic
Error: Statements discarded: 0
TEST01 INFORMATION Filter Summary: Invalid comment: Statements discarded: 0
TEST01 INFORMATION Filter Summary: Missing statistics: Statements discarded: 0
TEST01 INFORMATION Workload processing completed: 1 scanned 1 accepted 0 discarded
TEST01 INFORMATION No existing materialized views were found
desc user_advisor_recommendations
- Grid Control recommends the actions be accepted
SELECT type, rank, benefit, annotation_status
FROM user_advisor_recommendations
WHERE task_name = 'TEST01';
TYPE RANK BENEFIT ANNOTATION_
------------------------------ ----------
ACTIONS 1 4521 ACCEPT
desc user_advisor_actions
- View the recommended actions
col command format a30
col attr1 format a25
col attr3 format a25
col attr4 format a20
col attr5 format a100
col attr6 format a20
col error_message format a15
SELECT command, attr1, attr3, attr4
FROM user_advisor_actions
WHERE task_name = 'TEST01';
COMMAND ATTR1 ATTR3 ATTR4
------------------------------ ------------------------- ---------------
CREATE MATERIALIZED VIEW LOG "SCOTT"."TEMP01" ROWID
CREATE MATERIALIZED VIEW "SCOTT"."MV$$_07540000" REFRESH FAST WITH ROWID ENABLE QUERY REWRITE
GATHER TABLE STATISTICS "SCOTT"."MV$$_07540000" -1
set long 100000
SELECT attr5 FROM user_advisor_actions
WHERE task_name = 'TEST01';
ATTR5
--------------------------------------------------------
SELECT "SCOTT"."TEMP01"."OBJECT_NAME" M1
FROM SCOTT.TEMP01 WHERE
(SCOTT.TEMP01.OBJECT_ID = 1234)
desc user_advisor_log
SELECT execution_start, execution_end, status, error_message
FROM user_advisor_log WHERE task_name = 'TEST01';
EXECUTION EXECUTION STATUS ERROR_MESSAGE
--------- --------- ----------- ---------------
12-NOV-08 12-NOV-08 COMPLETED
desc user_advisor_tasks
col description format a15
col advisor_name format a20
col source format a20
col recommendation_count format 99
col how_created format a20
SELECT description, advisor_name, created, status,
recommendation_count, source, how_created
FROM user_advisor_tasks WHERE task_name = 'TEST01';
DESCRIPTION ADVISOR_NAME CREATED STATUS RECOMMENDATION_COUNT
--------------- -------------------- --------- ----------- --------------------
Quick Tune SQL Access Advisor 12-NOV-08 COMPLETED 1
SOURCE HOW_CREATED
---------- -------------------
SQLACCESS_GENERAL CMD
- Delete Task name
exec dbms_advisor.delete_task('TEST01');
From steps, we get recommendations and use them to improve performance about that sql statement.
dbms_advisor.quick_tune(
advisor_name IN VARCHAR2,
task_name IN VARCHAR2,
attr1 IN CLOB := NULL,
attr2 IN VARCHAR2 := NULL,
attr3 IN NUMBER := NULL,
template IN VARCHAR2 := NULL,
implement IN BOOLEAN := FALSE,
description IN VARCHAR2 := NULL);
Example to use dbms_advisor.quick_tune :
- create table for testing.
CREATE TABLE TEMP01 NOLOGGING AS SELECT * FROM ALL_OBJECTS;
ANALYZE TABLE TEMP01 COMPUTE STATISTICS;
A SQL Statement need to analyze : select object_name from temp01 where object_id=1234
- Begin analyze and get recommendation.
desc user_advisor_templates
set linesize 100
col task_name format a40
col description format a50
SELECT task_name, description FROM user_advisor_templates;
TASK_NAME DESCRIPTION
---------------------------------------- -----------------------
SQLACCESS_GENERAL General purpose database template
SQLACCESS_OLTP OLTP database template
SQLACCESS_WAREHOUSE Data Warehouse database template
SQLACCESS_EMTASK Default Enterprise Manager task template
desc user_advisor_journal
SELECT COUNT(*) FROM user_advisor_journal;
COUNT(*)
----------
0
DECLARE
task_name VARCHAR2(30) := 'TEST01';
BEGIN
dbms_advisor.quick_tune(dbms_advisor.sqlaccess_advisor, task_name,
'select object_name from temp01 where object_id=1234');
END;
/
SELECT COUNT(*) FROM user_advisor_journal;
COUNT(*)
----------
19
col task_name format a10
col journal_entry_type format a15
col journal_entry format a65
SELECT task_name, journal_entry_type, journal_entry
FROM user_advisor_journal WHERE task_name = 'TEST01';
TASK_NAME JOURNAL_ENTRY_T JOURNAL_ENTRY
---------- --------------- -----------------------
TEST01 INFORMATION Preparing workload for analysis
TEST01 INFORMATION Filter Summary: Valid username: Unused
TEST01 INFORMATION Filter Summary: Invalid username: Unused
TEST01 INFORMATION Filter Summary: Valid module: Unused
TEST01 INFORMATION Filter Summary: Invalid module: Unused
TEST01 INFORMATION Filter Summary: Valid action: Unused
TEST01 INFORMATION Filter Summary: Invalid action: Unused
TEST01 INFORMATION Filter Summary: Valid SQL String: Unused
TEST01 INFORMATION Filter Summary: Invalid SQL String: Statements discarded: 0
TEST01 INFORMATION Filter Summary: Invalid start time: Unused
TEST01 INFORMATION Filter Summary: Invalid end time: Unused
TEST01 INFORMATION Filter Summary: Invalid table: Unused
TEST01 INFORMATION Filter Summary: Valid table: Unused
TEST01 INFORMATION Filter Summary: Invalid table reference:
Statements discarded: 0
TEST01 INFORMATION Filter Summary: SQL Syntax or Semantic
Error: Statements discarded: 0
TEST01 INFORMATION Filter Summary: Invalid comment: Statements discarded: 0
TEST01 INFORMATION Filter Summary: Missing statistics: Statements discarded: 0
TEST01 INFORMATION Workload processing completed: 1 scanned 1 accepted 0 discarded
TEST01 INFORMATION No existing materialized views were found
desc user_advisor_recommendations
- Grid Control recommends the actions be accepted
SELECT type, rank, benefit, annotation_status
FROM user_advisor_recommendations
WHERE task_name = 'TEST01';
TYPE RANK BENEFIT ANNOTATION_
------------------------------ ----------
ACTIONS 1 4521 ACCEPT
desc user_advisor_actions
- View the recommended actions
col command format a30
col attr1 format a25
col attr3 format a25
col attr4 format a20
col attr5 format a100
col attr6 format a20
col error_message format a15
SELECT command, attr1, attr3, attr4
FROM user_advisor_actions
WHERE task_name = 'TEST01';
COMMAND ATTR1 ATTR3 ATTR4
------------------------------ ------------------------- ---------------
CREATE MATERIALIZED VIEW LOG "SCOTT"."TEMP01" ROWID
CREATE MATERIALIZED VIEW "SCOTT"."MV$$_07540000" REFRESH FAST WITH ROWID ENABLE QUERY REWRITE
GATHER TABLE STATISTICS "SCOTT"."MV$$_07540000" -1
set long 100000
SELECT attr5 FROM user_advisor_actions
WHERE task_name = 'TEST01';
ATTR5
--------------------------------------------------------
SELECT "SCOTT"."TEMP01"."OBJECT_NAME" M1
FROM SCOTT.TEMP01 WHERE
(SCOTT.TEMP01.OBJECT_ID = 1234)
desc user_advisor_log
SELECT execution_start, execution_end, status, error_message
FROM user_advisor_log WHERE task_name = 'TEST01';
EXECUTION EXECUTION STATUS ERROR_MESSAGE
--------- --------- ----------- ---------------
12-NOV-08 12-NOV-08 COMPLETED
desc user_advisor_tasks
col description format a15
col advisor_name format a20
col source format a20
col recommendation_count format 99
col how_created format a20
SELECT description, advisor_name, created, status,
recommendation_count, source, how_created
FROM user_advisor_tasks WHERE task_name = 'TEST01';
DESCRIPTION ADVISOR_NAME CREATED STATUS RECOMMENDATION_COUNT
--------------- -------------------- --------- ----------- --------------------
Quick Tune SQL Access Advisor 12-NOV-08 COMPLETED 1
SOURCE HOW_CREATED
---------- -------------------
SQLACCESS_GENERAL CMD
- Delete Task name
exec dbms_advisor.delete_task('TEST01');
From steps, we get recommendations and use them to improve performance about that sql statement.
Subscribe to:
Posts (Atom)