Timing a SQL query
Hi
Is there a way to time how long a SQL query takes to execute on the server itself? Currently I'm just whacking
declare @blah datetime
set @blah = getdate
select datediff(ms, @blah, getdate())
at the front and back of the passed SQL string and then taking the last result of the time. Now this works but I was wondering if there is some method in JDBC that would get you the same effedct without having to butcher the SQL code like I do
Was thinking about that and hoping to cut out network transmission time and whatever else Java might decide to do before actually executing the query (and if you have a slow pc that might also affect the Java time).
But yeah, sucks that JDBC doesn't have a feature like that. Oh well, I'll just leave it like it is (since the people I'm doing it for already said it's fine this way so if for some arb reason it breaks something, not my problem XD )
Similar Messages
-
How to Suppress The Output of a SQL Query In Oracle 11gR2
Hi Friends,
I am using oracle version 11.2.0.1, I have set a cronjob which will run on every 15 minutes and give us a log file mentioning the execution time taken for that SQL query:-
For example:
SQL> set timing on;
SQL> SELECT objProp FROM aradmin.arschema WHERE (schemaId = 175);
OBJPROP+
--------------------------------------------------------------------------------+
*6\60006\4\0\\60008\40\0\60009\4\0\\60010\4\0\\60018\4\0\\600*
*22\4\68\1\63\AR:jRL#*
Elapsed: 00:00:00.00
The above query will return the output as well as the time taken for execution of the query. I want to suppress the output of the query and only want the time taken to be printed. Is it possible by set commands. I have marked the output as bold and made it Italic.
Please help me at the earliest.
Regards,
Arijit>
I am using oracle version 11.2.0.1, I have set a cronjob which will run on every 15 minutes and give us a log file mentioning the execution time taken for that SQL query:-
The above query will return the output as well as the time taken for execution of the query. I want to suppress the output of the query and only want the time taken to be printed. Is it possible by set commands. I have marked the output as bold and made it Italic.
>
How would that even be useful?
A query from a tool such as sql*plus is STILL going to send the output to the client and the client. You can keep sql*plus from actually displaying the data by setting autotrace to trace only.
But that TIME TAKEN is still going to include the network time it takes to send ALL rows that the query returns across the network.
That time is NOT the same as the actual execution time of the query. So unless you are trying to determine how long it takes to send the data over the network your 'timing' method is rather flawed.
Why don't you tell us WHAT PROBLEM you are trying to solve so we can help you solve it? -
OutOfMemory error while executing sql query
Hello!
My program gets multiple datas from database in every ten minutes, and stores them in memory for hundreds of users, requesting datas via web-interface simoultaneously.
I dont have access to change database structures, write stored procedures, etc, just read from db.
There is a table in database with lot of million rows, and sometimes when I try to execute a SELECT on this table it takes minutes to get back the result.
To avoid waiting for database server for a long time, I set querytimeout to 30 seconds.
If the server throws back the execution with Query Timed out Exception, I want to 'forget' this data, and 0 value is acceptable because of fast run is more important. So I put the boolean broken variable to check if there is any problem with db server.
The size of the used memory is about 150Mb if things going well, but I set the max heap to 512 MB, just in case anything happens.
I'm logging all threads stacktrace, and free/used/allocated memory size in every 5 seconds.(threadwatching.log) 2.appendix
Sometimes, not in every case (I dont know what is this depends on), when I get the next phase of refreshing cached datas (you can see it below), the process reaches the fiorst checkpoint (signed in code below), starts to execute the sql query, and never reaches the second checkpoint , but used memory growing 50-60 Mb-os in every 5 seconds, as I can see in threadwatching.log until it reaches the max memory and throws OutOfMemory error: java heap space.
I'm using DbConnectionBroker for connection pooling, SQLCommandBean for handling Statements, PreparedStatements, etc, and jTDS jdbc connector.
SQLCommandBean closes statements, resultsets, so these objects doesnt stays open.
I cant figured out what causes the memory leak, if someone have an idea, please help me.
1. Part of the cached data refreshing (DataFactory.createPCVPPMforSiemens()):
PCVElement element = new PCVElement(m, ProcessControlView.PPM);
String s = DateTime.getDate(interval.getStartDate());
boolean broken=false;
int value = 0;
for (int j = 0; j < 48; j++) {
try {
if (!broken) {
d1 = DateTime.getDate(new Date(start + ((j + 1) * 600000)));
sqlBean = new SQLCommandBean();
conn = broker.getConnection();
sqlBean.setConnection(conn);
sqlBean.setQueryTimeOut(30);
System.out.println(DateTime.getDate(new Date())+" "+m.getName()+" "+j);// first checkpoint
value = SiemensWorks.getPCVPPM(sqlBean, statId, s, d1);
System.out.println(DateTime.getDate(new Date())+" "+m.getName()+" "+j);// second checkpoint
} else value=0;
} catch (Exception ex) {
System.out.println("ERROR: DataFactory.createPCVPPMforSiemens 1 :" + ex.getMessage());
ex.printStackTrace();
value = 0;
broken=true;
} finally {
try {
broker.freeConnection(conn);
} catch (Exception ex) {}
element.getAvgValues()[j] = value;
}2. SiemensWorks.getPCVPPM()
public static int getPCVPPM(SQLCommandBean sqlBean,int statID,String start,String end)
throws SQLException, UnsupportedTypeException, NoSuchColumnException {
sqlBean.setSqlValue(SiemensSQL.PCV_PPM);
Vector values=new Vector();
values.add(new StringValue(statID+""));
values.add(new StringValue(start));
values.add(new StringValue(end));
sqlBean.setValues(values);
Vector rows=sqlBean.executeQuery();
if (rows==null || rows.size()==0) return 0;
Row row=(Row)rows.firstElement();
try {
float ret=Float.parseFloat(row.getString(1));
if (ret<=0) ret=0;
return Math.round(ret);
} catch (Exception ex) {
return 0;
}3. Part of Threadwatching.log
2006-10-13 16:46:56 Name: SMT Refreshing Threads
2006-10-13 16:46:56 Thread count: 4
2006-10-13 16:46:56 Active count: 4
2006-10-13 16:46:56 Active group count: 0
2006-10-13 16:46:56 Daemon: false
2006-10-13 16:46:56 Priority: 5
2006-10-13 16:46:57 Free memory: 192,228,944 bytes
2006-10-13 16:46:57 Max memory: 332,988,416 bytes
2006-10-13 16:46:57 Memory in use: 140,759,472 bytes
2006-10-13 16:46:57 ---------------------------------
2006-10-13 16:46:57 0. Name: CachedLayerTimer
2006-10-13 16:46:57 0. Id: 19
2006-10-13 16:46:57 0. Priority: 5
2006-10-13 16:46:57 0. Parent: SMT Refreshing Threads
2006-10-13 16:46:57 0. State: RUNNABLE
2006-10-13 16:46:57 0. Alive: true
2006-10-13 16:46:57 java.io.FileOutputStream.close0(Native Method)
2006-10-13 16:46:57 java.io.FileOutputStream.close(Unknown Source)
2006-10-13 16:46:57 sun.nio.cs.StreamEncoder$CharsetSE.implClose(Unknown Source)
2006-10-13 16:46:57 sun.nio.cs.StreamEncoder.close(Unknown Source)
2006-10-13 16:46:57 java.io.OutputStreamWriter.close(Unknown Source)
2006-10-13 16:46:57 xcompany.smtmonitor.chart.ChartCreator.createChart(ChartCreator.java:663)
2006-10-13 16:46:57 xcompany.smtmonitor.chart.ChartCreator.create(ChartCreator.java:441)
2006-10-13 16:46:57 xcompany.smtmonitor.CachedLayerRefreshenerTask.run(CachedLayerRefreshenerTask.java:463)
2006-10-13 16:46:57 java.util.TimerThread.mainLoop(Unknown Source)
2006-10-13 16:46:57 java.util.TimerThread.run(Unknown Source)
Software runs well until I get the DataFactory.createPCVPPMforSiemens function in my code ->
2006-10-13 16:47:01 Name: SMT Refreshing Threads
2006-10-13 16:47:01 Thread count: 4
2006-10-13 16:47:01 Active count: 4
2006-10-13 16:47:01 Active group count: 0
2006-10-13 16:47:01 Daemon: false
2006-10-13 16:47:01 Priority: 5
2006-10-13 16:47:02 Free memory: 189,253,304 bytes
2006-10-13 16:47:02 Max memory: 332,988,416 bytes
2006-10-13 16:47:02 Memory in use: 143,735,112 bytes
2006-10-13 16:47:02 ---------------------------------
2006-10-13 16:47:02 0. Name: CachedLayerTimer
2006-10-13 16:47:02 0. Id: 19
2006-10-13 16:47:02 0. Priority: 5
2006-10-13 16:47:02 0. Parent: SMT Refreshing Threads
2006-10-13 16:47:02 0. State: RUNNABLE
2006-10-13 16:47:02 0. Alive: true
2006-10-13 16:47:02 java.util.LinkedList$ListItr.previous(Unknown Source)
2006-10-13 16:47:02 net.sourceforge.jtds.util.TimerThread.setTimer(TimerThread.java:174)
2006-10-13 16:47:02 net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3734)
2006-10-13 16:47:02 net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:997)
2006-10-13 16:47:02 net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:320)
2006-10-13 16:47:02 net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:667)
2006-10-13 16:47:02 xcompany.database.sql.SQLCommandBean.executeQuery(SQLCommandBean.java:91)
2006-10-13 16:47:02 xcompany.smtmonitor.data.SiemensWorks.getPCVPPM(SiemensWorks.java:409)
2006-10-13 16:47:02 xcompany.smtmonitor.data.DataFactory.createPCVPPMforSiemens(DataFactory.java:6103)
2006-10-13 16:47:02 xcompany.smtmonitor.data.DataFactory.refreshProcessControlView(DataFactory.java:5791)
2006-10-13 16:47:02 xcompany.smtmonitor.CachedLayerRefreshenerTask.run(CachedLayerRefreshenerTask.java:514)
2006-10-13 16:47:02 java.util.TimerThread.mainLoop(Unknown Source)
2006-10-13 16:47:02 java.util.TimerThread.run(Unknown Source)
2006-10-13 16:47:06 Name: SMT Refreshing Threads
2006-10-13 16:47:06 Thread count: 4
2006-10-13 16:47:06 Active count: 4
2006-10-13 16:47:06 Active group count: 0
2006-10-13 16:47:06 Daemon: false
2006-10-13 16:47:06 Priority: 5
2006-10-13 16:47:08 Free memory: 127,428,192 bytes
2006-10-13 16:47:08 Max memory: 332,988,416 bytes
2006-10-13 16:47:08 Memory in use: 205,560,224 bytes
2006-10-13 16:47:08 ---------------------------------
2006-10-13 16:47:08 0. Name: CachedLayerTimer
2006-10-13 16:47:08 0. Id: 19
2006-10-13 16:47:08 0. Priority: 5
2006-10-13 16:47:08 0. Parent: SMT Refreshing Threads
2006-10-13 16:47:08 0. State: RUNNABLE
2006-10-13 16:47:08 0. Alive: true
2006-10-13 16:47:08 java.util.LinkedList$ListItr.previous(Unknown Source)
2006-10-13 16:47:08 net.sourceforge.jtds.util.TimerThread.setTimer(TimerThread.java:174)
2006-10-13 16:47:08 net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3734)
2006-10-13 16:47:08 net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:997)
2006-10-13 16:47:08 net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:320)
2006-10-13 16:47:08 net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:667)
2006-10-13 16:47:08 xcompany.database.sql.SQLCommandBean.executeQuery(SQLCommandBean.java:91)
2006-10-13 16:47:08 xcompany.smtmonitor.data.SiemensWorks.getPCVPPM(SiemensWorks.java:409)
2006-10-13 16:47:08 xcompany.smtmonitor.data.DataFactory.createPCVPPMforSiemens(DataFactory.java:6103)
2006-10-13 16:47:08 xcompany.smtmonitor.data.DataFactory.refreshProcessControlView(DataFactory.java:5791)
2006-10-13 16:47:08 xcompany.smtmonitor.CachedLayerRefreshenerTask.run(CachedLayerRefreshenerTask.java:514)
2006-10-13 16:47:08 java.util.TimerThread.mainLoop(Unknown Source)
2006-10-13 16:47:08 java.util.TimerThread.run(Unknown Source)
2006-10-13 16:47:12 Name: SMT Refreshing Threads
2006-10-13 16:47:12 Thread count: 4
2006-10-13 16:47:12 Active count: 4
2006-10-13 16:47:12 Active group count: 0
2006-10-13 16:47:12 Daemon: false
2006-10-13 16:47:12 Priority: 5
2006-10-13 16:47:15 Free memory: 66,760,208 bytes
2006-10-13 16:47:15 Max memory: 332,988,416 bytes
2006-10-13 16:47:15 Memory in use: 266,228,208 bytes
2006-10-13 16:47:15 ---------------------------------
2006-10-13 16:47:15 0. Name: CachedLayerTimer
2006-10-13 16:47:15 0. Id: 19
2006-10-13 16:47:15 0. Priority: 5
2006-10-13 16:47:15 0. Parent: SMT Refreshing Threads
2006-10-13 16:47:15 0. State: RUNNABLE
2006-10-13 16:47:15 0. Alive: true
2006-10-13 16:47:15 java.util.LinkedList.addBefore(Unknown Source)
2006-10-13 16:47:15 java.util.LinkedList.access$300(Unknown Source)
2006-10-13 16:47:15 java.util.LinkedList$ListItr.add(Unknown Source)
2006-10-13 16:47:15 net.sourceforge.jtds.util.TimerThread.setTimer(TimerThread.java:175)
2006-10-13 16:47:15 net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3734)
2006-10-13 16:47:15 net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:997)
2006-10-13 16:47:15 net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:320)
2006-10-13 16:47:15 net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:667)
2006-10-13 16:47:15 xcompany.database.sql.SQLCommandBean.executeQuery(SQLCommandBean.java:91)
2006-10-13 16:47:15 xcompany.smtmonitor.data.SiemensWorks.getPCVPPM(SiemensWorks.java:409)
2006-10-13 16:47:15 xcompany.smtmonitor.data.DataFactory.createPCVPPMforSiemens(DataFactory.java:6103)
2006-10-13 16:47:15 xcompany.smtmonitor.data.DataFactory.refreshProcessControlView(DataFactory.java:5791)
2006-10-13 16:47:15 xcompany.smtmonitor.CachedLayerRefreshenerTask.run(CachedLayerRefreshenerTask.java:514)
2006-10-13 16:47:15 java.util.TimerThread.mainLoop(Unknown Source)
2006-10-13 16:47:15 java.util.TimerThread.run(Unknown Source)
2006-10-13 16:47:17 Name: SMT Refreshing Threads
2006-10-13 16:47:17 Thread count: 4
2006-10-13 16:47:17 Active count: 4
2006-10-13 16:47:17 Active group count: 0
2006-10-13 16:47:17 Daemon: false
2006-10-13 16:47:17 Priority: 5
2006-10-13 16:47:20 Free memory: 23,232,496 bytes
2006-10-13 16:47:20 Max memory: 332,988,416 bytes
2006-10-13 16:47:20 Memory in use: 309,755,920 bytes
2006-10-13 16:47:20 ---------------------------------
2006-10-13 16:47:20 0. Name: CachedLayerTimer
2006-10-13 16:47:20 0. Id: 19
2006-10-13 16:47:20 0. Priority: 5
2006-10-13 16:47:20 0. Parent: SMT Refreshing Threads
2006-10-13 16:47:20 0. State: RUNNABLE
2006-10-13 16:47:20 0. Alive: true
2006-10-13 16:47:20 net.sourceforge.jtds.util.TimerThread.setTimer(TimerThread.java:171)
2006-10-13 16:47:20 net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3734)
2006-10-13 16:47:20 net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:997)
2006-10-13 16:47:20 net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:320)
2006-10-13 16:47:20 net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:667)
2006-10-13 16:47:20 xcompany.database.sql.SQLCommandBean.executeQuery(SQLCommandBean.java:91)
2006-10-13 16:47:20 xcompany.smtmonitor.data.SiemensWorks.getPCVPPM(SiemensWorks.java:409)
2006-10-13 16:47:20 xcompany.smtmonitor.data.DataFactory.createPCVPPMforSiemens(DataFactory.java:6103)
2006-10-13 16:47:20 xcompany.smtmonitor.data.DataFactory.refreshProcessControlView(DataFactory.java:5791)
2006-10-13 16:47:20 xcompany.smtmonitor.CachedLayerRefreshenerTask.run(CachedLayerRefreshenerTask.java:514)
2006-10-13 16:47:20 java.util.TimerThread.mainLoop(Unknown Source)
2006-10-13 16:47:20 java.util.TimerThread.run(Unknown Source)
2006-10-13 16:47:23 Name: SMT Refreshing Threads
2006-10-13 16:47:23 Thread count: 4
2006-10-13 16:47:23 Active count: 4
2006-10-13 16:47:23 Active group count: 0
2006-10-13 16:47:23 Daemon: false
2006-10-13 16:47:23 Priority: 5
2006-10-13 16:47:26 Free memory: 4,907,336 bytes
2006-10-13 16:47:26 Max memory: 332,988,416 bytes
2006-10-13 16:47:26 Memory in use: 328,083,768 bytes
2006-10-13 16:47:26 ---------------------------------
2006-10-13 16:47:26 0. Name: CachedLayerTimer
2006-10-13 16:47:26 0. Id: 19
2006-10-13 16:47:26 0. Priority: 5
2006-10-13 16:47:26 0. Parent: SMT Refreshing Threads
2006-10-13 16:47:26 0. State: RUNNABLE
2006-10-13 16:47:26 0. Alive: true
2006-10-13 16:47:26 java.util.LinkedList.addBefore(Unknown Source)
2006-10-13 16:47:26 java.util.LinkedList.access$300(Unknown Source)
2006-10-13 16:47:26 java.util.LinkedList$ListItr.add(Unknown Source)
2006-10-13 16:47:26 net.sourceforge.jtds.util.TimerThread.setTimer(TimerThread.java:175)
2006-10-13 16:47:26 net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3734)
2006-10-13 16:47:26 net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:997)
2006-10-13 16:47:26 net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:320)
2006-10-13 16:47:26 net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:667)
2006-10-13 16:47:26 xcompany.database.sql.SQLCommandBean.executeQuery(SQLCommandBean.java:91)
2006-10-13 16:47:26 xcompany.smtmonitor.data.SiemensWorks.getPCVPPM(SiemensWorks.java:409)
2006-10-13 16:47:26 xcompany.smtmonitor.data.DataFactory.createPCVPPMforSiemens(DataFactory.java:6103)
2006-10-13 16:47:26 xcompany.smtmonitor.data.DataFactory.refreshProcessControlView(DataFactory.java:5791)
2006-10-13 16:47:26 xcompany.smtmonitor.CachedLayerRefreshenerTask.run(CachedLayerRefreshenerTask.java:514)
2006-10-13 16:47:26 java.util.TimerThread.mainLoop(Unknown Source)
2006-10-13 16:47:26 java.util.TimerThread.run(Unknown Source)
2006-10-13 16:47:35 Name: SMT Refreshing Threads
2006-10-13 16:47:37 Thread count: 4
2006-10-13 16:47:38 Active count: 4
2006-10-13 16:47:38 Active group count: 0
2006-10-13 16:47:38 Daemon: false
2006-10-13 16:47:38 Priority: 5
2006-10-13 16:47:42 Free memory: 35,316,120 bytes
2006-10-13 16:47:42 Max memory: 332,988,416 bytes
2006-10-13 16:47:42 Memory in use: 297,672,296 bytes
2006-10-13 16:47:42 ---------------------------------
2006-10-13 16:47:42 0. Name: CachedLayerTimer
2006-10-13 16:47:42 0. Id: 19
2006-10-13 16:47:42 0. Priority: 5
2006-10-13 16:47:42 0. Parent: SMT Refreshing Threads
2006-10-13 16:47:42 0. State: TIMED_WAITING
2006-10-13 16:47:42 0. Alive: true
2006-10-13 16:47:42 java.lang.Object.wait(Native Method)
2006-10-13 16:47:42 java.util.TimerThread.mainLoop(Unknown Source)
2006-10-13 16:47:42 java.util.TimerThread.run(Unknown Source)
4. Tomcat default logging file:
2006-10-13 16:47:36 ERROR CachedLayerRefreshenerTask: external error: Java heap space
5. DbConnectionBroker (connection pooling) logging file:
Handing out connection 1 --> 10/13/2006 04:47:01 PM
Handing out connection 0 --> 10/13/2006 04:47:01 PM
Handing out connection 1 --> 10/13/2006 04:47:01 PM
Handing out connection 0 --> 10/13/2006 04:47:02 PM
Warning. Connection 0 in use for 3141 ms
Warning. Connection 0 in use for 24891 ms
----> Error: Could not free connection!!!
I would appreciate for any help.What does your query bring back from this table?This is the query:
SELECT case sum(c.picked) when 0 then 0 else
((sum(c.picked)-(sum(c.picked)-(sum(c.vacuum)+sum(c.id
ent))))*cast((1000000/cast(sum(c.picked) as float))
as bigint)) end as PPM
FROM sip_comp c
LEFT JOIN sip_pcb pc ON pc.id=c.pcbid
LEFT JOIN sip_period p on p.id=pc.periodid
WHERE p.stationid=? AND pc.time BETWEEN ? AND ?Has anybody who knows SQL tried EXPLAIN PLAN to optimize this table? You're joining on a table with a million rows and you're wondering why the performance is poor?
What is the index situation with these tables?
.> When I execute it from query manager, it takes from 1
to 60 secs depend on servers availability. So how will that be any different for JDBC and Java?
..> You're right. Thats why I am here.
What I mean by that is we can't read minds, either. You need to get some hard data to tell you where the bottleneck is. Asking at a forum won't help.
But tell me, if the java process enters to this query
execution, and doesnt quit until OOM thrown, how can
be the problem in caching?I was guessing about caching, because I didn't know what the query was.
You expect a lot.
.> No.
Then how do you ever expect to solve this?
I tried YourKit Profiler at home, where I'm
developing software, but this OOM never thrown here,
even if I have the same database size.Then you aren't replicating the problem. You have to run it on the system that has the problem if you're going to solve it.
YourKit isn't an industry leader. How well do you know how to use it?
It just happened at the company where the system
runs, and I cannot run this profiler there because
the PC where my tomcat runs dramatically slowed.You have to run something to figure out what the problem is. What about Log4J, some trace logging statements and a batch job to harvest the log?
Bottom line: you've got to be a scientist and get some real data. We can theorize all we want here, but that won't get you to a solution.
% -
How to estimated time for oracle sql query
i have query run every month on production server to collect some information
data size is difference every month
what i need to estimate the time before running
how can i do thatsorry this is what i get
when i caculate time column it give me 10 sec
but when i make this
SQL> set timing on;
SQL> select * from tab;
3658 rows selected.
Elapsed: 00:00:05.50
so whay in the first give me 10 sec and the secand give me 5.50 sec
SQL> explain plan for select * from tab;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 457676135
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1243 | 104K| 182 (4)| 00:00:03 |
| 1 | NESTED LOOPS OUTER | | 1243 | 104K| 182 (4)| 00:00:03 |
|* 2 | TABLE ACCESS FULL | OBJ$ | 1243 | 98197 | 142 (5)| 00:00:02 |
| 3 | TABLE ACCESS CLUSTER| TAB$ | 1 | 7 | 1 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | I_OBJ# | 1 | | 0 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
2 - filter("O"."TYPE#"<=5 AND "O"."OWNER#"=USERENV('SCHEMAID') AND
"O"."TYPE#">=2 AND "O"."LINKNAME" IS NULL)
4 - access("O"."OBJ#"="T"."OBJ#"(+))
18 rows selected.
SQL>
Edited by: 862640 on Nov 27, 2011 1:43 AM
Edited by: 862640 on Nov 27, 2011 1:49 AM
Edited by: 862640 on Nov 27, 2011 1:53 AM -
How can we see how long our SQL query took to execute?
or
set timing on
in sql*plus if you just want a basic idea. -
How to compare same SQL query performance in different DB servers.
We have Production and Validation Environment of Oracle11g DB on two Solaris OSs.
H/W and DB,etc configurations of two Oracle DBs are almost same in PROD and VAL.
But we detected large SQL query performace difference in PROD DB and VAL DB in same SQL query.
I would like to find and solve the cause of this situation.
How could I do that ?
I plan to compare SQL execution plan in PROD and VAL DB and index fragmentations.
Before that I thought I need to keep same condition of DB statistics information in PROD and VAL DB.
So, I plan to execute alter system FLUSH BUFFER_CACHE;
But I am worring about bad effects of alter system FLUSH BUFFER_CACHE; to end users
If we did alter system FLUSH BUFFER_CACHE; and got execution plan of that SQL query in the time end users do not use that system ,
there is not large bad effect to end users after those operations?
Could you please let me know the recomendation to compare SQL query performace ?Thank you.
I got AWR report for only VAL DB server but it looks strange.
Is there any thing wrong in DB or how to get AWR report ?
Host Name
Platform
CPUs
Cores
Sockets
Memory (GB)
xxxx
Solaris[tm] OE (64-bit)
.00
Snap Id
Snap Time
Sessions
Cursors/Session
Begin Snap:
xxxx
13-Apr-15 04:00:04
End Snap:
xxxx
14-Apr-15 04:00:22
Elapsed:
1,440.30 (mins)
DB Time:
0.00 (mins)
Report Summary
Cache Sizes
Begin
End
Buffer Cache:
M
M
Std Block Size:
K
Shared Pool Size:
0M
0M
Log Buffer:
K
Load Profile
Per Second
Per Transaction
Per Exec
Per Call
DB Time(s):
0.0
0.0
0.00
0.00
DB CPU(s):
0.0
0.0
0.00
0.00
Redo size:
Logical reads:
0.0
1.0
Block changes:
0.0
1.0
Physical reads:
0.0
1.0
Physical writes:
0.0
1.0
User calls:
0.0
1.0
Parses:
0.0
1.0
Hard parses:
W/A MB processed:
16.7
1,442,472.0
Logons:
Executes:
0.0
1.0
Rollbacks:
Transactions:
0.0
Instance Efficiency Percentages (Target 100%)
Buffer Nowait %:
Redo NoWait %:
Buffer Hit %:
In-memory Sort %:
Library Hit %:
96.69
Soft Parse %:
Execute to Parse %:
0.00
Latch Hit %:
Parse CPU to Parse Elapsd %:
% Non-Parse CPU:
Shared Pool Statistics
Begin
End
Memory Usage %:
% SQL with executions>1:
34.82
48.31
% Memory for SQL w/exec>1:
63.66
73.05
Top 5 Timed Foreground Events
Event
Waits
Time(s)
Avg wait (ms)
% DB time
Wait Class
DB CPU
0
100.00
Host CPU (CPUs: Cores: Sockets: )
Load Average Begin
Load Average End
%User
%System
%WIO
%Idle
Instance CPU
%Total CPU
%Busy CPU
%DB time waiting for CPU (Resource Manager)
Memory Statistics
Begin
End
Host Mem (MB):
SGA use (MB):
46,336.0
46,336.0
PGA use (MB):
713.6
662.6
% Host Mem used for SGA+PGA:
Time Model Statistics
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Operating System Statistics
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Operating System Statistics - Detail
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Foreground Wait Class
s - second, ms - millisecond - 1000th of a second
ordered by wait time desc, waits desc
%Timeouts: value of 0 indicates value was < .5%. Value of null is truly 0
Captured Time accounts for % of Total DB time .00 (s)
Total FG Wait Time: (s) DB CPU time: .00 (s)
Wait Class
Waits
%Time -outs
Total Wait Time (s)
Avg wait (ms)
%DB time
DB CPU
0
100.00
Back to Wait Events Statistics
Back to Top
Foreground Wait Events
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Background Wait Events
ordered by wait time desc, waits desc (idle events last)
Only events with Total Wait Time (s) >= .001 are shown
%Timeouts: value of 0 indicates value was < .5%. Value of null is truly 0
Event
Waits
%Time -outs
Total Wait Time (s)
Avg wait (ms)
Waits /txn
% bg time
log file parallel write
527,034
0
2,209
4
527,034.00
db file parallel write
381,966
0
249
1
381,966.00
os thread startup
2,650
0
151
57
2,650.00
latch: messages
125,526
0
89
1
125,526.00
control file sequential read
148,662
0
54
0
148,662.00
control file parallel write
41,935
0
28
1
41,935.00
Log archive I/O
5,070
0
14
3
5,070.00
Disk file operations I/O
8,091
0
10
1
8,091.00
log file sequential read
3,024
0
6
2
3,024.00
db file sequential read
1,299
0
2
2
1,299.00
latch: shared pool
722
0
1
1
722.00
enq: CF - contention
4
0
1
208
4.00
reliable message
1,316
0
1
1
1,316.00
log file sync
71
0
1
9
71.00
enq: CR - block range reuse ckpt
36
0
0
13
36.00
enq: JS - queue lock
459
0
0
1
459.00
log file single write
414
0
0
1
414.00
enq: PR - contention
5
0
0
57
5.00
asynch descriptor resize
67,076
100
0
0
67,076.00
LGWR wait for redo copy
5,184
0
0
0
5,184.00
rdbms ipc reply
1,234
0
0
0
1,234.00
ADR block file read
384
0
0
0
384.00
SQL*Net message to client
189,490
0
0
0
189,490.00
latch free
559
0
0
0
559.00
db file scattered read
17
0
0
6
17.00
resmgr:internal state change
1
100
0
100
1.00
direct path read
301
0
0
0
301.00
enq: RO - fast object reuse
35
0
0
2
35.00
direct path write
122
0
0
1
122.00
latch: cache buffers chains
260
0
0
0
260.00
db file parallel read
1
0
0
41
1.00
ADR file lock
144
0
0
0
144.00
latch: redo writing
55
0
0
1
55.00
ADR block file write
120
0
0
0
120.00
wait list latch free
2
0
0
10
2.00
latch: cache buffers lru chain
44
0
0
0
44.00
buffer busy waits
3
0
0
2
3.00
latch: call allocation
57
0
0
0
57.00
SQL*Net more data to client
55
0
0
0
55.00
ARCH wait for archivelog lock
78
0
0
0
78.00
rdbms ipc message
3,157,653
40
4,058,370
1285
3,157,653.00
Streams AQ: qmn slave idle wait
11,826
0
172,828
14614
11,826.00
DIAG idle wait
170,978
100
172,681
1010
170,978.00
dispatcher timer
1,440
100
86,417
60012
1,440.00
Streams AQ: qmn coordinator idle wait
6,479
48
86,413
13337
6,479.00
shared server idle wait
2,879
100
86,401
30011
2,879.00
Space Manager: slave idle wait
17,258
100
86,324
5002
17,258.00
pmon timer
46,489
62
86,252
1855
46,489.00
smon timer
361
66
86,145
238628
361.00
VKRM Idle
1
0
14,401
14400820
1.00
SQL*Net message from client
253,909
0
419
2
253,909.00
class slave wait
379
0
0
0
379.00
Back to Wait Events Statistics
Back to Top
Wait Event Histogram
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Wait Event Histogram Detail (64 msec to 2 sec)
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Wait Event Histogram Detail (4 sec to 2 min)
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Wait Event Histogram Detail (4 min to 1 hr)
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Service Statistics
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
Service Wait Class Stats
No data exists for this section of the report.
Back to Wait Events Statistics
Back to Top
SQL Statistics
SQL ordered by Elapsed Time
SQL ordered by CPU Time
SQL ordered by User I/O Wait Time
SQL ordered by Gets
SQL ordered by Reads
SQL ordered by Physical Reads (UnOptimized)
SQL ordered by Executions
SQL ordered by Parse Calls
SQL ordered by Sharable Memory
SQL ordered by Version Count
Complete List of SQL Text
Back to Top
SQL ordered by Elapsed Time
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by CPU Time
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by User I/O Wait Time
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by Gets
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by Reads
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by Physical Reads (UnOptimized)
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by Executions
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by Parse Calls
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by Sharable Memory
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
SQL ordered by Version Count
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
Complete List of SQL Text
No data exists for this section of the report.
Back to SQL Statistics
Back to Top
Instance Activity Statistics
Instance Activity Stats
Instance Activity Stats - Absolute Values
Instance Activity Stats - Thread Activity
Back to Top
Instance Activity Stats
No data exists for this section of the report.
Back to Instance Activity Statistics
Back to Top
Instance Activity Stats - Absolute Values
No data exists for this section of the report.
Back to Instance Activity Statistics
Back to Top
Instance Activity Stats - Thread Activity
Statistics identified by '(derived)' come from sources other than SYSSTAT
Statistic
Total
per Hour
log switches (derived)
69
2.87
Back to Instance Activity Statistics
Back to Top
IO Stats
IOStat by Function summary
IOStat by Filetype summary
IOStat by Function/Filetype summary
Tablespace IO Stats
File IO Stats
Back to Top
IOStat by Function summary
'Data' columns suffixed with M,G,T,P are in multiples of 1024 other columns suffixed with K,M,G,T,P are in multiples of 1000
ordered by (Data Read + Write) desc
Function Name
Reads: Data
Reqs per sec
Data per sec
Writes: Data
Reqs per sec
Data per sec
Waits: Count
Avg Tm(ms)
Others
28.8G
20.55
.340727
16.7G
2.65
.198442
1803K
0.01
Direct Reads
43.6G
57.09
.517021
411M
0.59
.004755
0
LGWR
19M
0.02
.000219
41.9G
21.87
.496493
2760
0.08
Direct Writes
16M
0.00
.000185
8.9G
1.77
.105927
0
DBWR
0M
0.00
0M
6.7G
4.42
.079670
0
Buffer Cache Reads
3.1G
3.67
.037318
0M
0.00
0M
260.1K
3.96
TOTAL:
75.6G
81.33
.895473
74.7G
31.31
.885290
2065.8K
0.51
Back to IO Stats
Back to Top
IOStat by Filetype summary
'Data' columns suffixed with M,G,T,P are in multiples of 1024 other columns suffixed with K,M,G,T,P are in multiples of 1000
Small Read and Large Read are average service times, in milliseconds
Ordered by (Data Read + Write) desc
Filetype Name
Reads: Data
Reqs per sec
Data per sec
Writes: Data
Reqs per sec
Data per sec
Small Read
Large Read
Data File
53.2G
78.33
.630701
8.9G
7.04
.105197
0.37
21.51
Log File
13.9G
0.18
.164213
41.9G
21.85
.496123
0.02
2.93
Archive Log
0M
0.00
0M
13.9G
0.16
.164213
Temp File
5.6G
0.67
.066213
8.1G
0.80
.096496
5.33
3713.27
Control File
2.9G
2.16
.034333
2G
1.46
.023247
0.05
19.98 -
Reg : Exection time of SQL query
Hi All,
How to identify the oracle sql query exection time.
Thanks in Advance.Hi,
try This
SQL> set timing on;
SQL> select * from dual;
D
X
Elapsed: 00:00:00.00
SQL> set timing off;
SQL> select * from dual;
D
XReagrds
umi -
hello,
I want to calculate the sql query execution time.Like my query is
select column,,,,, from tab;
I want to know how much time it consumed to return results.
How can I do so?SET TIMING
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12040.htm#SQPUG063
Adith -
I'd like to know if there is any easy, and convenient way, for someone to execute an SQL query an calculate, these measurments relative to the query:
1) The I/O performed
2)Number Read I/O
3) Number of Write out I/O
(such that 2+3 = 1
4) Number of buffered reads
5)Query Execution time
6) Query CPU usage
I've heard mention of such statisctis in views such as V$OSSTAT, etc.
But these views give the current values, and not the specific cumulative values. Such as: cummulative CPU usage time since start of the query; cumulative I/O since query begin, etc...
What is the right approach to this. Is it through the V$SESSION view? Would you about it by storing the V$SESSIOn values before the query, you run the query, and get the new V$SESSION values?Well, actually i stayed here a little longer to try you part 2 of the manual.
It worked fine, following comes the output, originating from a spool file, of my first experiment:
Connected.
SQL> set timing on trimspool on linesize 250 pagesize 999
SQL>
SQL> -- system environment can be checked with:
SQL> -- show parameter statis
SQL> -- this show a series of parameters related to statistics
SQL>
SQL> -- this setting can influence your sorting
SQL> -- in particular if an index can satisfy your sort order
SQL> -- alter session set nls_language = 'AMERICAN';
SQL>
SQL>
SQL> rem Set the ARRAYSIZE according to your application
SQL> set arraysize 15 termout off
SQL>
SQL> spool diag2.log
SQL>
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'))
PLAN_TABLE_OUTPUT
SQL_ID b4j5rmwug3u8p, child number 0
SELECT USRID, FAVF FROM (SELECT ID as USRID, FAVF1, FAVF2, FAVF3,
FAVF4, FAVF5 FROM PROFILE) P UNPIVOT (FAVF FOR CNAME IN ( FAVF1,
FAVF2, FAVF3, FAVF4, FAVF5)) FAVFRIEND
Plan hash value: 888567555
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time |
Buffers |
| 0 | SELECT STATEMENT | | 1 | | 5 |00:00:00.01 |
8 |
|* 1 | VIEW | | 1 | 5 | 5 |00:00:00.01 |
8 |
| 2 | UNPIVOT | | 1 | | 5 |00:00:00.01 |
8 |
| 3 | TABLE ACCESS FULL| PROFILE | 1 | 1 | 1 |00:00:00.01 |
8 |
Predicate Information (identified by operation id):
1 - filter("unpivot_view_013"."FAVF" IS NOT NULL)
Note
- dynamic sampling used for this statement
26 rows selected.
Elapsed: 00:00:00.14
SQL>
SQL> spool off
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Pr
oduction
With the OLAP, Data Mining and Real Application Testing options
C:\Documents and Settings\Administrator\My Documents\scripts\oracle\99templates_
autotrace>my_part2_template.bat
C:\Documents and Settings\Administrator\My Documents\scripts\oracle\99templates_
autotrace>sqlplus /NOLOG @my_part2_template.sql
SQL*Plus: Release 11.1.0.7.0 - Production on Qui Jul 9 22:00:39 2009
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Connected.
SQL> set timing on trimspool on linesize 250 pagesize 999
SQL>
SQL> -- system environment can be checked with:
SQL> -- show parameter statis
SQL> -- this show a series of parameters related to statistics
SQL>
SQL> -- this setting can influence your sorting
SQL> -- in particular if an index can satisfy your sort order
SQL> -- alter session set nls_language = 'AMERICAN';
SQL>
SQL>
SQL> rem Set the ARRAYSIZE according to your application
SQL> set arraysize 15 termout off
SQL>
SQL> spool diag2.log
SQL>
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'))
PLAN_TABLE_OUTPUT
SQL_ID b4j5rmwug3u8p, child number 0
SELECT USRID, FAVF FROM (SELECT ID as USRID, FAVF1, FAVF2, FAVF3,
FAVF4, FAVF5 FROM PROFILE) P UNPIVOT (FAVF FOR CNAME IN ( FAVF1,
FAVF2, FAVF3, FAVF4, FAVF5)) FAVFRIEND
Plan hash value: 888567555
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time |
Buffers |
| 0 | SELECT STATEMENT | | 1 | | 5 |00:00:00.01 |
8 |
|* 1 | VIEW | | 1 | 5 | 5 |00:00:00.01 |
8 |
| 2 | UNPIVOT | | 1 | | 5 |00:00:00.01 |
8 |
| 3 | TABLE ACCESS FULL| PROFILE | 1 | 1 | 1 |00:00:00.01 |
8 |
Predicate Information (identified by operation id):
1 - filter("unpivot_view_013"."FAVF" IS NOT NULL)
Note
- dynamic sampling used for this statement
26 rows selected.
Elapsed: 00:00:00.01
SQL>
SQL> spool off
SQL>
SQL>
SQL> -- rem End of Part 2
SQL> show parameter statis
NAME TYPE VALUE
optimizer_use_pending_statistics boolean FALSE
statistics_level string ALL
timed_os_statistics integer 5
timed_statistics boolean TRUE
SQL> quitIf you notice, at the end of the execution I print my statistics session environment. The statistics_level was set to ALL, as you advisied. But the output I obtained seems a lot more incomplete than the one I got from using the autotrace feature.
Am I missing something. Could it have something to do with the fact that I am running as system and not as sysdba? System shoul have enough permissions to access its session environment statistic values.
May be it's just a language issue (I'm not a native speaker either) but your understanding of Oracle's read consistency model seems to be questionable.No, you could be right; my understanding is questionable indeed. I am familiar with general concepts of concurrency.
Things like: Read uncommited data:
T1 Writes A; T2 Reads A -> Here is a conflict
This enough for you to not be able to guarantee that the execution is serializable.
T1 Reads A, T2 Writes A and commits, T1 Reads A - You get another confli, the Unrepeatable read.
And so on.
I am also familiar with the different levels of atomicity that databse systems in general give you.
Conflict Serializable, normally implemented by using the strict phase locking mechanism.
Repeatable Reads, you lock the rows you access during a transaction. You are guaranteed that those data values you access do not change value; but other entires in the table could be put.
Unrepeatable reads. Only the data you modify is guaranteed to stay the same. Only you write locks are kept throughout the transaction. And so on.
But anyway...
What you explained in your post is more or less what I was saying. In you case much more clear than in mine.
For instance, if a thread T1 reads A; a thread T2 Writes on A
In oracle, you could have the thread T1 read A again without geting an Unrepeatable Read error. This is strange: in a normal system you directly get an exception telling you that your vision of the system is inconsistent. But in oracel you can do so, because oracle tries to fetch from the Undo Table Space that same data objects consistent with the view of the system you had when you first accessed it. It looks for a block with an an SCN older than the current version SCN. Or something like that. The only problem is that those modified blocks do not stay indefinitely there. Once a transaction commits you have a time bomb in your hands. That is, if you are working with that is not at its most current version.
But you are quite right, I have not read enough about Oracle concurrency. But I have a good enough understanding for mu current needs.
I can not know everything, nor do i want to :D.
My memory is very limited.
My best regards, and deepest thanks for your time and attention.
Edited by: user10282047 on Jul 9, 2009 2:41 PM -
[Excel] Running a SQL Query to delete rows
Hello Experts,
Background: I am attempting to use a dba of my companies time keeping system and implement it with Power BI tools. Given the file size restrictions within Power Bi itself I need to lower my file size by removing all time logs from
inactive employees.
I have a question regarding whether or not you can use a sql query to delete rows in excel. I have roughly 200,000+ rows in my excel spreadsheet. I am attempting to delete all rows where an employee equals inactive. I have attempted to
delete these rows by sorting them and doing a bulk delete and clear contents, but it seems to crash my excel every time. My thought process is that using a query that does a timed delete might put less of a burden on deleting the massive amount of data.
I would like to use this: DELETE * FROM [Table_(...)_Actual$] WHERE [Current] = "Inactive" (Will add more once I know it is possible to use sql queries in Excel.
Any information on whether or not this is possible would be appreciated.
Regards,
LinkRunning SQL Query in Excel is possible, however, the delete query is not supported in Excel.
You are more restricted in deleting Excel data than data from a relational data source. In a relational database, "row" has no meaning or existence apart from "record"; in an Excel worksheet, this is not true. You can delete values
in fields (cells). Please see:http://support.microsoft.com/kb/257819/en-us
One workaround : Use update query to set the rows as null, then use select query.
e.g.
SQL = "update [sheet2$A1:B5] set name=null,age=null where name='andy'"
cnn.Execute SQL
SQL = "select name,age from [sheet2$A1:B5] where name is not null"
Wind Zhang
TechNet Community Support -
How to analyze sql query?
Hi,
can i analyze the performance of my sql query?
How to analyze my sql queries performance?
How to write optimal query?
Thanks & Regardscan i analyze the performance of my sql query? Yes!
How to analyze my sql queries performance?With a stopwatch. Or a trace, or SET TIMING ON.
How to write optimal query?Have a look at this post:
When your query takes too long ... -
How to modify a SQL query?
Hi all,
I am using Crystal Reports version 10. I have a number of reports that have been written by a software vendor wherby the name of the database they were connected to when the report was written is coded into the FROM command of the reports SQL query, eg "GCUK_2" in the of the SQL snippet below.
SELECT "Clients"."NAME", "Quotes"."QUOTE_ID", "Quote_Items"."UPRICE", "Quote_Items"."QTY", "Quote_Items"."UOM", "Quote_Items"."QUSAGE_ID", "Report_Control"."QUSAGEID", "Quote_Items"."STANDARD", "Quote_Items"."SECT_FLAG", "Quote_Items"."DISPORDER", "Quotes"."DESCRIPT", "Report_Control"."SECT_NAME", "Quote_Items"."CNT", "Category_and_Type"."TYPEDESC", "Quote_Items"."DESCRIPT", "Report_Control"."DISP_SORT"
FROM ((("GCUK_2"."schedwin"."QTE_CTRL" "Report_Control" INNER JOIN "GCUK_2"."schedwin"."QUSAGE" "Quote_Items" ON "Report_Control"."QUSAGEID"="Quote_Items"."QUSAGE_ID") LEFT OUTER JOIN "GCUK_2"."schedwin"."QUOTES" "Quotes" ON
I have tried setting the Datasource Location, but it doesn't change the query at all. I have read on another forum that you can generate another SQL query using the Database Expert, Current Connections, then right click the Add Command for the database you want to create a SQL command. Is this the only way to update the database names in the query?
Thanks,
Scott.Hi Sourashree,
Thanks for that. All the reports were created by the vendor using tables as opposed to the command object. I would have thought that changing the datasource would automatically cause Crystal to rewrite the SQL query syntax, but this doesn't appear to be the case.
Yes, I've noticed that modifying the record selection will change the sql query. The only way I can see to change the database name in the query is to change to the desired databsource and then remove and re-insert the tables, which will then update the query with the correct name. However, this seems to be a convoluted way of changing the db name in the query. -
Discoverer Report showing Null VS Show SQL query showing results !!!
I created a simple Cross Tab Discoverer report from a custom SQL which has a calculation for balances. The output is giving all null values even though there are balances. The output doesn't seem right. So I copied the query from Tools-->Show SQL and ran the query in the TOAD where I'm showing balances for the report. I don't understand why it is not showing in the discoverer. Please help.
Thanks
Edited by: PA1B on Jan 27, 2010 11:40 AMSorry for late reply.
Below is the Show SQL query. I don't think the query is application dependent. C_1 is my calculation.
SELECT o279709.SEGMENT3 as E279727,
o279709.SEGMENT4 as E279728,
CASE WHEN o279709.CURRENCY_CODE = 'USD' AND o279709.TRANSLATED_FLAG <> 'Y' THEN SUM(o279709.ENDING_BAL) ELSE 0 END as C_1,
GROUPING_ID(o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG) as GID
FROM ( --Foriegn Entity USD Balances
SELECT B.SEGMENT1,
B.SEGMENT2,
B.SEGMENT3,
(select distinct substr(cat.COMPILED_VALUE_ATTRIBUTES,5,1) from apps.fnd_flex_values cat
where FLEX_VALUE_SET_ID = (select bat.FLEX_VALUE_SET_ID from apps.fnd_id_flex_structures_vl aat, apps.fnd_id_flex_segments_vl bat
where bat.id_flex_code = 'GL#' and
bat.id_flex_code = aat.id_flex_code and
aat.APPLICATION_ID = bat.APPLICATION_ID and
aat.APPLICATION_ID = 101 and
bat.SEGMENT_NAME = 'Prime Account' and
aat.id_flex_num = bat.id_flex_num
and bat.id_flex_num in (select distinct chart_of_accounts_id from apps.gl_code_combinations gat
where gat.code_combination_id = A.code_combination_id))
and cat.flex_value = b.segment3) ACCT_TYPE ,
B.SEGMENT4,
B.SEGMENT5,
B.SEGMENT6,
B.SEGMENT7,
B.SEGMENT8,
B.SEGMENT9,
B.SEGMENT10,
B.SEGMENT11,
B.SEGMENT12,
B.SEGMENT13,
C.NAME,
A.SET_OF_BOOKS_ID,
A.CURRENCY_CODE,A.TRANSLATED_FLAG,
SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0)) BEG_BAL,
SUM(NVL(A.PERIOD_NET_DR,0)) DEBITS,
SUM( NVL(A.PERIOD_NET_CR,0)) CREDITS ,
A.PERIOD_NAME,
SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0))+ SUM(NVL(A.PERIOD_NET_DR,0) - NVL(A.PERIOD_NET_CR,0)) ENDING_BAL
FROM APPS.GL_BALANCES A ,
APPS.GL_CODE_COMBINATIONS B,
APPS.GL_SETS_OF_BOOKS C
WHERE A.CODE_COMBINATION_ID = B.CODE_COMBINATION_ID
--AND A.PERIOD_NAME = 'SEP-09'
AND C.SET_OF_BOOKS_ID = A.SET_OF_BOOKS_ID
--AND A.TRANSLATED_FLAG <> 'Y'
--AND B.SEGMENT1 = '83101'
--AND B.SEGMENT3 = '14602'
--AND A.SET_OF_BOOKS_ID = 77
--AND A.CURRENCY_CODE = 'USD'
GROUP BY A.CODE_COMBINATION_ID,
B.SEGMENT1,
B.SEGMENT2,
B.SEGMENT3,
B.SEGMENT4,
B.SEGMENT5,
B.SEGMENT6,
B.SEGMENT7,
B.SEGMENT8,
B.SEGMENT9,
B.SEGMENT10,
B.SEGMENT11,
B.SEGMENT12,
B.SEGMENT13,
A.CURRENCY_CODE,
A.TRANSLATED_FLAG,
C.NAME,A.PERIOD_NAME,
A.SET_OF_BOOKS_ID
) o279709
WHERE (o279709.PERIOD_NAME = 'DEC-09')
AND (o279709.SET_OF_BOOKS_ID <> 72)
AND (o279709.SEGMENT12 = '000')
AND (o279709.SEGMENT3 IN ('10101','10301','10502','12001'))
AND (o279709.SEGMENT1 IN ('82901','82902','82903','83001','83003','83201'))
GROUP BY GROUPING SETS(( o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG ),( o279709.SEGMENT3,o279709.SEGMENT4 ),( o279709.SEGMENT3 ))
HAVING (GROUP_ID()=0)
ORDER BY GID DESC;
Thanks,
PA1
Edited by: PA1B on Jan 29, 2010 12:50 PM -
Error while executing a sql query for select
HI All,
ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
1. I dont want to increase the temp space
2. I need to tune the query, please provide your recomendations.
insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
(REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
select
REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
carrier_item_type,carried_item_protection_type,'PACS'
from
(select distinct
c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
a.carrier_item_type,a.carried_item_protection_type,'PACS'
from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
AND a.carrier_items=b.mux
and c.REPORTNUMBER=(case
when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
else 20
end)
and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
where not exists
(select *
from CST_DSA.HIERARCHY_MISMATCHES B where
A.REPORTNUMBER=B.REPORT_NUM and
A.REPORTTYPE=B.REPORT_TYPE and
A.REPORTDESCRIPTION=B.REPORT_DESC and
A.CARRIED_ITEMS=B.CARRIED_ITEMS and
A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
A.CARRIER_ITEMS=B.CARRIER_ITEMS and
A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
AND B.SOURCE_SYSTEM='PACS'
Explain Plan
==========
Plan
INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1
20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES
19 PX COORDINATOR
18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1
17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1
15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1
4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621
3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448
11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448
8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002
7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2
6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2
5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448
9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448
13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1
12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1
16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1 -
Issue in creation of group in oim database through sql query.
hi guys,
i am trying to create a group in oim database through sql query:
insert into ugp(ugp_key,ugp_name,ugp_create,ugp_update,ugp_createby,ugp_updateby,)values(786,'dbrole','09-jul-12','09-jul-12',1,1);
it is inserting the group in ugp table but it is not showing in admin console.
After that i also tried with this query:
insert into gpp(ugp_key,gpp_ugp_key,gpp_write,gpp_delete,gpp_create,gpp_createby,gpp_update,gpp_updateby)values(786,1,1,1,'09-jul-12',1,'09-jul-12',1);
After that i tried with this query.but still no use.
and i also tried to assign a user to the group through query:
insert into usg(ugp_key,usr_key,usg_priority,usg_create,usg_update,usg_createby,usg_updateby)values(4,81,1,'09-jul-12','09-jul-12',1,1);
But still the same problem.it is inserting in db.but not listing in admin console.
thanks,
hanuman.Hanuman Thota wrote:
hi vladimir,
i didn't find this 'ugp_seq'.is this a table or column?where is it?
It is a sequence.
See here for details on oracle sequences:
http://www.techonthenet.com/oracle/sequences.php
Most of the OIM database schema is created with the following script, located in the RCU distribution:
$RCU_HOME/rcu/integration/oim/sql/xell.sql
there you'll find plenty of sequence creation directives like:
create sequence UGP_SEQ
increment by 1
start with 1
cache 20
to create a sequence, and
INSERT INTO UGP (UGP_KEY, UGP_NAME, UGP_UPDATEBY, UGP_UPDATE, UGP_CREATEBY, UGP_CREATE,UGP_ROWVER, UGP_DATA_LEVEL, UGP_ROLE_CATEGORY_KEY, UGP_ROLE_OWNER_KEY, UGP_DISPLAY_NAME, UGP_ROLENAME, UGP_DESCRIPTION, UGP_NAMESPACE)
VALUES (ugp_seq.nextval,'SYSTEM ADMINISTRATORS', sysadmUsrKey , SYSDATE,sysadmUsrKey , SYSDATE, hextoraw('0000000000000000'), 1, roleCategoryKey, sysadmUsrKey, 'SYSTEM ADMINISTRATORS', 'SYSTEM ADMINISTRATORS', 'System Administrator role for OIM', 'Default');
as a sequence usage example.
Regards,
Vladimir
Maybe you are looking for
-
Help, I am upgrading a PC for a friend and have replaced the standard 128Mb PC100 ram with a matched pair of 256Mb PC133 DIMMs but the PC refuses to see any more than 128Mb. I have flashed the BIOS to 1.7 without any difference. Is there a setting in
-
How to get the amout(menge),unit price(netpr) and sum of consignment PO
hi expert: Because there are no netpr and netwr of consignment PO in EKPO table, i want to know that how i can get the amout(menge),unit price(netpr) and sum(netwr) of the material in this consignment PO between a definite time. would y
-
Gateway M-1631u laptop bluetooth driver
I recently upgraded my laptop from windows vista to windows 7.. I went to the manufacturers website to download all the drivers but I ran into a little issue with my Bluetooth.. the driver's installation wizard keeps telling me that there is no Bluet
-
CATA: time sheet: transfer to target components
Could you please please give me an overview of what CATA (t-code) does? I have done some config in sandbox: I booked time in cat2 with a sender cost ctr + activity type and receiver cost center in ECC 6.0. With out running cata (t-code), I was able t
-
RFC destination - INTEGRATION_DIRECTORY_HMI
While creating the <b>RFC destination - INTEGRATION_DIRECTORY_HMI</b>in the integration server, on logon & security tab, what is the user that should be given. As the source is ID, I thought it could be PIDIRUSER. Correct me -Naveen.