How to tune the performance of Oracle SQL/XML query?
Hi all,
I am running Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
SELECT XMLElement("CUSTOMER",
XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
(SELECT XMLAgg(XMLElement("ORDERS",
XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
(SELECT XMLAgg(XMLElement("LINEITEM",
XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
FROM LINEITEM
WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
FROM ORDERS
WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
FROM CUSTOMER ;
Thanks very much in advance for your time,
Jinghao Liu
ajallen wrote:
Why not something more like
SELECT *
FROM fact1 l,
FULL OUTER JOIN fact1 d
ON l.company = d.company
AND l.transactiontypeid = 1
AND d.transactiontypeid = 2;
Because this is not an equivalent of the original query.
drop table t1 cascade constraints purge;
drop table t2 cascade constraints purge;
create table t1 as select rownum t1_id from dual connect by level <= 5;
create table t2 as select rownum+2 t2_id from dual connect by level <= 5;
select * from (select * from t1 where t1_id > 2) t1 full outer join t2 on (t1_id = t2_id);
select * from t1 full outer join t2 on (t1_id = t2_id and t1_id > 2);
T1_ID T2_ID
3 3
4 4
5 5
6
7
T1_ID T2_ID
1
2
3 3
4 4
5 5
6
7
Similar Messages
-
How to perf tune Oracle SQL/XML query?
Hi all,
I am using Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
SELECT XMLElement("CUSTOMER",
XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
(SELECT XMLAgg(XMLElement("ORDERS",
XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
(SELECT XMLAgg(XMLElement("LINEITEM",
XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
FROM LINEITEM
WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
FROM ORDERS
WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
FROM CUSTOMER ;
Thanks very much in advance for your time,
Jinghao LiuPlease post this message at:
Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB -
How to measure the performance of a SQL query?
Hello,
I want to measure the performance of a group of SQL queries to compare them, but i don't know how to do it.
Is there any application to do it?
Thanks.You can use STATSPACK (in 10g its called as AWR - Automatic Workload Repository)
Statspack -> A set of SQL, PL/SQL, and SQL*Plus scripts that allow the collection, automation, storage, and viewing of performance data. This feature has been replaced by the Automatic Workload Repository.
Automatic Workload Repository - Collects, processes, and maintains performance statistics for problem detection and self-tuning purposes
Oracle Database Performance Tuning Guide - Automatic Workload Repository
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/autostat.htm#PFGRF02601
or
you can use EXPLAIN PLAN
EXPLAIN PLAN -> A SQL statement that enables examination of the execution plan chosen by the optimizer for DML statements. EXPLAIN PLAN causes the optimizer to choose an execution plan and then to put data describing the plan into a database table.
Oracle Database Performance Tuning Guide - Using EXPLAIN PLAN
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#PFGRF009
Oracle Database SQL Reference - EXPLAIN PLAN
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9010.htm#sthref8881 -
How to check the datfiles from oracle SQL Developer(enterprise Manager)
hi,
Iam using Oracle SQL Developer as enterprise manager in my local pc.I want to check the size of datafiles using this enterprise manager.could u pls help me out..
Thanks in advance ,
R.RatheeshWhat?
Sql developer is not enterprise manager.
Size of datafiles? Read the documention, and read the concepts and administration manuals for your release.
I am not going to provide links, because you have not given your database version number and secondly if you found this forum you can find the docs.
But I will give you a clue....DBA_DATA_FILES...
Message was edited by:
bazzza -
How to break the line in Oracle SQL?
Hi All,
I have a long text with comma separated value. I am storing that in to one custom table as it is. But i want to store that with next line i mean split the comma separated line and insert into the table table with next line or new line character.
For example: My long text is A, B, C, D, E, F
I need to insert like below in the table.
A
B
C
D
E
FWe'd also like the reverse functionality: to have the ability to take a single comma-delimited value and treat it as if it were a column in a table. We can take advantage of the TABLE SQL function and PL/SQL function tables to do this quite easily, but first, we must define the result type to be a TABLE type of the largest possible string.
create or replace type split_tbl as table of varchar2(32767);
show errors;
create or replace function split
p_list varchar2,
p_del varchar2 := ','
) return split_tbl pipelined
is
l_idx pls_integer;
l_list varchar2(32767) := p_list;
AA
l_value varchar2(32767);
begin
loop
l_idx := instr(l_list,p_del);
if l_idx > 0 then
pipe row(substr(l_list,1,l_idx-1));
l_list := substr(l_list,l_idx+length(p_del));
else
pipe row(l_list);
exit;
end if;
end loop;
return;
end split;
show errors;
With this function, I can run a query like this:
SQL> select * from table(split('one,two,three'));
one
two
three -
How to measure the performance of sql query?
Hi Experts,
How to measure the performance, efficiency and cpu cost of a sql query?
What are all the measures available for an sql query?
How to identify i am writing optimal query?
I am using Oracle 9i...
It ll be useful for me to write efficient query....
Thanks & Regardspsram wrote:
Hi Experts,
How to measure the performance, efficiency and cpu cost of a sql query?
What are all the measures available for an sql query?
How to identify i am writing optimal query?
I am using Oracle 9i... You might want to start with a feature of SQL*Plus: The AUTOTRACE (TRACEONLY) option which executes your statement, fetches all records (if there is something to fetch) and shows you some basic statistics information, which include the number of logical I/Os performed, number of sorts etc.
This gives you an indication of the effectiveness of your statement, so that can check how many logical I/Os (and physical reads) had to be performed.
Note however that there are more things to consider, as you've already mentioned: The CPU bit is not included in these statistics, and the work performed by SQL workareas (e.g. by hash joins) is also credited only very limited (number of sorts), but e.g. it doesn't cover any writes to temporary segments due to sort or hash operations spilling to disk etc.
You can use the following approach to get a deeper understanding of the operations performed by each row source:
alter session set statistics_level=all;
alter session set timed_statistics = true;
select /* findme */ ... <your query here>
SELECT
SUBSTR(LPAD(' ',DEPTH - 1)||OPERATION||' '||OBJECT_NAME,1,40) OPERATION,
OBJECT_NAME,
CARDINALITY,
LAST_OUTPUT_ROWS,
LAST_CR_BUFFER_GETS,
LAST_DISK_READS,
LAST_DISK_WRITES,
FROM V$SQL_PLAN_STATISTICS_ALL P,
(SELECT *
FROM (SELECT *
FROM V$SQL
WHERE SQL_TEXT LIKE '%findme%'
AND SQL_TEXT NOT LIKE '%V$SQL%'
AND PARSING_USER_ID = SYS_CONTEXT('USERENV','CURRENT_USERID')
ORDER BY LAST_LOAD_TIME DESC)
WHERE ROWNUM < 2) S
WHERE S.HASH_VALUE = P.HASH_VALUE
AND S.CHILD_NUMBER = P.CHILD_NUMBER
ORDER BY ID
/Check the V$SQL_PLAN_STATISTICS_ALL view for more statistics available. In 10g there is a convenient function DBMS_XPLAN.DISPLAY_CURSOR which can show this information with a single call, but in 9i you need to do it yourself.
Note that "statistics_level=all" adds a significant overhead to the processing, so use with care and only when required:
http://jonathanlewis.wordpress.com/2007/11/25/gather_plan_statistics/
http://jonathanlewis.wordpress.com/2007/04/26/heisenberg/
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
How can I fine tune the performance of my IMS5.1 mailserver?
I installed the IMS5.1 on Solaris 8 with default parameters, without IDA. It is used as a mail relay. It seems to have/keep about 700 msgs in the tcp_local channel but none in the process channel. It uses the cpu very much, in my opinion too much (100% is no exception. It uses the swap file for only 30%. How can I tune the performance of my system. Don't laugh: the "server" is only a SUN Ultra 5 workstation.
I've been working with this MTA since '95. Unfortunately there is no easy answer. The number of msgs in queue is not an indication of performance, it can be, but it can also be that the hosts your system is trying to reach are not available. You can use tools like imsimta qtop to see top subjects or top domains. Poke around and see just why you have 700 msgs in your queues.
Channels like process or say conversion channel are internal while channnels like tcp_local deal with external systems. If you had mail backing up in the conversion channel then you'd have a good sign of local performance problems. Mail backing up in tcp_local is not necessarily a sign of performance problems on your end.
I don't see a problem with the software using all available CPU. What is wrong with that?
If you've made any changes to the configuration it could be that you have introduced something that is causing say a mapping process to loop and thus eat more CPU that would otherwise be normal.
What process is using all of this CPU? Knowing this would help to determine what part of the MTA might be using lots of CPU. -
How to check the performance of the database instance in oracle apps 11i
hii everybody,
i want to know,how to check the performance of the database instance using oracle applications 11i.your help highly appreciated,thanks.Pl do not post duplicates - how to check the performance of the server in oracle applications 11i
-
How to check the performance of the server in oracle applications 11i
hii everybody,
i want to know,how to check the performance of the system(test server) using oracle applications 11i.your help highly appreciated,thanks.938946 wrote:
hii everybody,
i want to know,how to check the performance of the system(test server) using oracle applications 11i.your help highly appreciated,thanks.Please see old threads for the same topic/discussion -- https://forums.oracle.com/forums/search.jspa?threadID=&q=Performance+AND+Tuning&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein -
How to tune the query and difference between CBO AND RBO.. Which is good
Hello Friends,
Here are some questions I have pls reply back with complete description and url if any ..
1)How Did you tune Query,
2)What approach you take to tune query? Do you use Hints?
3)Where did you tune the query and what are the issue with query?
4)What is difference between RBO and CBO? where u use RBO and CBO.
5)Give some information about hash join?
6) Using explain plan how do u know where the bottle neck in query .. how u will identify where the bottle neck is from explain plan .
thanks/KumarHi,
kumar73 wrote:
Hello Friends,
Here are some questions I have pls reply back with complete description and url if any ..
1)How Did you tune Query, Use EXPLAIN PLAN to see exactly where it is spending its time, and address those areas.
See the forum FAQ
SQL and PL/SQL FAQ
"3. How to improve the performance of my query?"
2)What approach you take to tune query? Do you use Hints?Hints can help.
Even more helpful is writing the SQL efficiently (avoiding multiple scans of the same table, filtering early, using built-in rather than user-defined functions, ...), creating and using indexes, and, for large tables, partitioning.
Table design can have a big impact on performace.
Look for ways to do part of what you need before the query. This includes denormalizing (when appropriate), the kind of pre-digesting that often takes place in data warehouses, function-based indexes, and, starting in Oracle 11, virtual columns.
3)Where did you tune the query and what are the issue with query?Either this question is a vague summary of the entire thread, or I don't understand it. Can you re-phrase this part?
4)What is difference between RBO and CBO? where u use RBO and CBO.Basically, use RBO if you have Oracle 7 or earlier. -
How to Tune the Transactions/ Z - reports /Progr..of High response time
Dear friends,
in <b>ST03</b> work load anlysis menu.... there are some z-reports, transactions, and some programmes are noticed contineously that they are taking the <b>max. response time</b> (and mostly >90%of time is DB Time ).
how to tune the above situation ??
Thank u.Siva,
You can start with some thing like:
ST04 -> Detail Analysis -> SQL Request (look at top disk reads and buffer get SQL statements)
For the top SQL statements identified you'd want to look at the explain plan to determine if the SQL statements is:
1) inefficient
2) are your DB stats up to date on the tables (note up to date stats does not always means they are the best)
3) if there are better indexes available, if not would a more suitable index help?
4) if there are many slow disk reads, is there an I/O issue?
etc...
While you're in ST04 make sure your buffers are sized adequately.
Also make sure your Oracle parameters are set according to this OSS note.
Note 830576 - Parameter recommendations for Oracle 10g -
How to increase OID performance ( compared to SQL )
I have an OID directory with about 100,000 entries in it. One
portion of our DIT has about 43,000 entries that use UID as part
of the DN.
If I need to get a list of the valid UIDs, it takes a very long
time to do it via OID. Since I know a little about how OID
stores the data inside Oracle, I know how to write an SQL
statement to pull out the data. ( I know, I am not supposed to
do this...)
The point is that if I use ldapsearch, the query takes about 2.5
minutes, which the SQL query takes only 11 seconds.
This would seem to me to indicate that it is an OID issue, not a
database issue. How can I tune OID to make this process go
faster?
Bob
[email protected]
p.s. If you are interested, here is what I am doing.
date
ldapsearch -D cn=orcladmin -w welcome \
-b ou=account,o=lilly,dc=com uid=* uid \
> ldap_uid.out
date
cat <<EOF > get_uids.sql
host date
set termout off
set pagesize 0
set trimspool on
set echo off
set verify off
set feedback off
spool icux3001.uid
select attrvalue from ods.ct_uid u, ods.ct_dn d
where u.entryid=d.entryid
and d.parentdn='dc=com,o=lilly,ou=account,';
spool off
set termout on
host date
exit
EOF
sqlplus / @get_uids.sql
Here is the output from that script.
$ ./compare_ldap.ksh
Connected to: PRODUCTION ENTERPRISE DIRECTORY SERVICE ON ICUX3001
Wed Oct 10 15:10:38 EST 2001
Wed Oct 10 15:13:12 EST 2001
SQL*Plus: Release 8.1.7.0.0 - Production on Wed Oct 10 15:13:13
2001
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
JServer Release 8.1.7.0.0 - Production
Wed Oct 10 15:13:13 EST 2001
Wed Oct 10 15:13:24 EST 2001
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.0.0 -
ProductionI would like to add the original question. I putan OID on my NT
workstation. I am running a JNDI stress-test program from a
separate server, doing 300 lookups. I run an initial prime to
make sure everything gets into memory, then a second test. In
theory it seems to me that it should be entirely memory
lookups. The CPU and memory stats look fine from NT Task
Manager. However, during the test I can hear the disk drive
going tap-tap-tap; obviously it is being hit again and again.
When I run statspack (granted, this is a very short test) the
following is said:
Top Wait Events
sort segment request: 1 wait, 103 wait time (cs)
db file sequential read: 33 waits, 71 wait time
control file parallel write: 14 waits, 38 wait time
control file sequential read: 37 waits, 35 wait time
So, why are there so many sequential file reads and writes? Is
it something with redo? Later on the report says:
redo blocks written 479
redo entries 209 -
How to increase the performance of an insert query?
Hi,
I am using oracle database for our application where we executes one insert query and need the performance of 300 insert queries to be executed per second.
As of now we are getting only 30/sec.We are not knowing how to tune the database for getting this performance.
we are doing all this though C programming under both linux and solaris environment.
Can u guide me in this issue.
Regards,
vamsi krishnaPerformance tuning issue is not something you can get a straight forward answer for.
You need to look at various aspects of the system to get close to or increase the performance of your application. Tuning just the database might not give you want you want.
So, you need to look at the Application codes, Mermory, Disk IO, etc. Have a look at the Performance Tuning Guide from the Oracle Documentation Library for your Oracle Release and Operating System
http://www.oracle.com/technology/documentation/index.html#previous -
How to print a something in oracle sql developer
Hello all
Do you know How to print a something in oracle sql developer? i mean for example in the query we write something, (offcourse i dont mean comments)
thank u in advance.
best1003209 wrote:
Hello all
Do you know How to print a something in oracle sql developer? i mean for example in the query we write something, (offcourse i dont mean comments)
thank u in advance.
bestDBMS_OUTPUT() -
How to improve the performance of the abap program
hi all,
I have created an abap program. And it taking long time since the number of records are more. And can anyone let me know how to improve the performance of my abap program.
Using se30 and st05 transaction.
can anyone help me out step by step
regds
harithaHi Haritha,
->Run Any program using SE30 (performance analysis)
Note: Click on the Tips & Tricks button from SE30 to get performance improving tips.
Using this you can improve the performance by analyzing your code part by part.
->To turn runtim analysis on within ABAP code insert the following code
SET RUN TIME ANALYZER ON.
->To turn runtim analysis off within ABAP code insert the following code
SET RUN TIME ANALYZER OFF.
->Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
->Avoid for all entries in JOINS
->Try to avoid joins and use FOR ALL ENTRIES.
->Try to restrict the joins to 1 level only ie only for tables
->Avoid using Select *.
->Avoid having multiple Selects from the same table in the same object.
->Try to minimize the number of variables to save memory.
->The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
->Avoid creation of index as far as possible
->Avoid operators like <>, > , < & like % in where clause conditions
->Avoid select/select single statements in loops.
->Try to use 'binary search' in READ internal table. -->Ensure table is sorted before using BINARY SEARCH.
->Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
->Avoid using ORDER BY in selects
->Avoid Nested Selects
->Avoid Nested Loops of Internal Tables
->Try to use FIELD SYMBOLS.
->Try to avoid into Corresponding Fields of
->Avoid using Select Distinct, Use DELETE ADJACENT
Check the following Links
Re: performance tuning
Re: Performance tuning of program
http://www.sapgenie.com/abap/performance.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
check the below link
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
See the following link if it's any help:
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
Check also http://service.sap.com/performance
and
books like
http://www.sap-press.com/product.cfm?account=&product=H951
http://www.sap-press.com/product.cfm?account=&product=H973
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
Performance tuning for Data Selection Statement
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
Debugger
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
http://www.cba.nau.edu/haney-j/CIS497/Assignments/Debugging.doc
http://help.sap.com/saphelp_erp2005/helpdata/en/b3/d322540c3beb4ba53795784eebb680/frameset.htm
Run Time Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
SQL trace
http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
CATT - Computer Aided Testing Too
http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
Test Workbench
http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
Coverage Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
Runtime Monitor
http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
Memory Inspector
http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
ECATT - Extended Computer Aided testing tool.
http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
Just refer to these links...
performance
Performance
Performance Guide
performance issues...
Performance Tuning
Performance issues
performance tuning
performance tuning
You can go to the transaction SE30 to have the runtime analysis of your program.Also try the transaction SCI , which is SAP Code Inspector.
edited by,
Naveenan
Maybe you are looking for
-
I have Product Activation Keys but I can't find the software for download.
-
Function 'SO_DOCUMENT_SEND_API1' in BADI
I am encountering difficulty using the function module 'SO_DOCUMENT_SEND_API1' in a BADI; when the BADI executes the mail is partially created (new entries exits in table SOOD) it is however not sent nor is it viewable in BWP. Executing the same co
-
SAP Crystal report toolbar doesn't appear
I have Crystal report which looks like below in browser window i want to design the crystal report . I didn't want the group tree to show . And the toolbar doesn't show in the top of the browser. And i also need the watermark image in the center of t
-
SAP report CNS41 to show different currencies
Hi, One of our User from Client side is having one Project in Currency GBP. He want to display CNS41 report for this Project in SEK currency. We have explored and found that it is possible to display CNS41 report either in GBP (Project currency) or
-
SOAP HandlerChain class not invoked
I've seen lots of posts about getting a HandlerChain class invoked, but I can't seem to find the magic cure. I have an EJB web service with the HandlerChain annotation and a SOAP handler and a handler-chain.xml file. But the handler does not get invo