Execution time of a query
Hi,
I am trying to find the execution time of a SQL query.
How to do it?
Regards.
Ashish
>I am trying to find the execution time of a SQL query.
How to do it?
Psuedo code:
time = SystemTime() -- get the current system time
RunSQL() -- run the SQL statement
print( SystemTime()-time ) -- displays the difference in time
Needless to say that this is utterly useless most of the time. The first time a query is run it may be subjected to a hard parse. The second time not. So the exact same SQL will show different execution times. This execution time measurement is useless as it does not tell you anything - except that there was a difference in time.
The first time a query runs it make do a lot of physical I/O to read the data from disk. The second time around, with the data in the db buffer cache, it makes use of logical I/O. There is a significant difference in the execution of the exact same SQL. Again, the measurement of execution is meaningless. It does not tell you anything. One number versus another number. Nothing meaningful to compare.
Fact. The very same SQL will have different execution times.
So what do you hope to gain from measuring it?
Similar Messages
-
Execution time of sql query differing a lot between two computer
hi
execution time of a query in my computer and more than 30 different computer is less than one second but on one of our
customers' computers, execution time is more than ten minute. databases and data and queries are same. i re-install sql but problem remains. my sql is ms sql 2008 r2.
any one has idea for this problem?Hi mahdi,
Obviously, we can't get enough information to help you troubleshoot this issue. So, please elaborate your issue with more detail so that the community members can help you in more effecient manner.
In addition, here is a good article regarding checklist for analyzing Slow-Running queries. Please see:
http://technet.microsoft.com/en-us/library/ms177500(v=sql.105).aspx
And SQL Server Profiler and Performance Monitor are good tools to troubleshoot performance issue, please see:
Correlating SQL Server Profiler with Performance Monitor:
https://www.simple-talk.com/sql/database-administration/correlating-sql-server-profiler-with-performance-monitor/
Regards,
Elvis Long
TechNet Community Support -
Need a Query to Get Execution time of each query in Proc if its running
I am looking for query which give total execution time of individual query running currently ?
we have queries but it will give cumulative time from the start date,
for example - if stored proc has 10 queries , if each query taking 10 seconds it should show me 10 secoond if its running, not from when stored proc execution started , if you have any query please let me know
only for running queries ,Is this the logic you're after?
DECLARE @timeStamp DATETIME2 = CURRENT_TIMESTAMP, @lapTimeStamp DATETIME2, @x INT = 0
SET @lapTimeStamp = CURRENT_TIMESTAMP
WHILE @x < 10000
BEGIN
SET @x = @x + 1
END
PRINT CAST(DATEDIFF(MS,@TIMESTAMP,CURRENT_TIMESTAMP) AS VARCHAR) + ' milliseconds have elapsed since the begining of the proc. ' + CAST(DATEDIFF(MS,@lapTimeStamp,CURRENT_TIMESTAMP) AS VARCHAR) + ' have elapsed since the last batch'
SET @lapTimeStamp = CURRENT_TIMESTAMP
SET @x = 0
WHILE @x < 10000
BEGIN
SET @x = @x + 1
END
PRINT CAST(DATEDIFF(MS,@TIMESTAMP,CURRENT_TIMESTAMP) AS VARCHAR) + ' milliseconds have elapsed since the begining of the proc. ' + CAST(DATEDIFF(MS,@lapTimeStamp,CURRENT_TIMESTAMP) AS VARCHAR) + ' have elapsed since the last batch'
SET @lapTimeStamp = CURRENT_TIMESTAMP
SET @x = 0
WHILE @x < 10000
BEGIN
SET @x = @x + 1
END
PRINT CAST(DATEDIFF(MS,@TIMESTAMP,CURRENT_TIMESTAMP) AS VARCHAR) + ' milliseconds have elapsed since the begining of the proc. ' + CAST(DATEDIFF(MS,@lapTimeStamp,CURRENT_TIMESTAMP) AS VARCHAR) + ' have elapsed since the last batch' -
How to find the execution time of a query?
hi guys,
i need to find the execution time of a query.
i tried finding it in rsrt but couldn find the execution time.
pleasse let me know the way to do it..
regards
sagarHi sagar,
If you want to know the frontend time, first of all you need to maitain the BW Statistics. To maintain you have to go the respective target and click on it. Go to the tools, select BW Statistics of infoprovider. It pop ups a window there you find two check boxes 1) WHM and 2) Front end time. Check both.
Now Exe query and close the analyzer. Then go to SE11 table RSDDSTAT. There is one field which displays Frentend time.
OR
Go to STO3 here also you can analys the frontend time.
If you feel useful Assign Pts.
Regards,
Vishal -
Query Execution Time for a Query causing ORA-1555
dear Gurus
I have ORA-01555 error , earlier I used the Query Duration mentioned in Alert Log and increased the Undo Retention as I did not find th UnDOBLKS column of v$undostat high for the time of occurence of ORA-01555..
But new ORA-01555 is coming whose query duration exceeds Undo Retention time..
My question -
1. Is it possible to accurately find the query duration time besides the Alert Log file ?abhishek, as you are using an undo tablespace and have already increased the time that undo data is retained via undo_retention then you might want to consider the following ideas which were useful with 1555 error under manual rbs segment management.
1- Tune the query. The faster a query runs the less likely a 1555 will occur.
2- Look at the processing. If a process was reading and updating the same table while committing frequenctly then the process under manual rbs management would basically create its own 1555 error rather than just being the victum of another process changing data and the rbs data being overlaid while the long running query was still running. With undo management the process could be generating more data than can be held for the undo_retention period but because it is committed Oracle has been told it doesn't really have to keep the data for use rolling back a current transaction so it gets discarded to make room for new changes.
If you find item 2 is true then separating the select from the update will likely eliminate the 1555. You do this by building a driving table that has the keys of the rows to be updated or deleted. Then you use the driver to control accessing the target table.
3- If the cause of the 1555 is or may be delayed block cleanout then select * from the target prior to running the long running query.
Realistically you might need to increase the size of the undo tablespace to hold all the change data and the value of the undo_retention parameter to be longer than the job run time. Which brings up back to option 1. Tune every query in the process so that the job run time is reduced to optimal.
HTH -- Mark D Powell --
dear mark
Thanks for the excellent advise..I found that the error is coming because of frequent commits..which is item 2 as u righly mentioned ..
I think I need to keep a watch on the queries running , I was just trying to find the execution time for the queries..If there is any way to find the query duration without running a trace ..
regards
abhishek -
How to get the execution time of a query
Hi,
Environment: 10.2.0.4.0
Just wondering how I can get the query execution time? I am not interested in the query output nor do I want the statistics, just the execution time?
Any suggestions will be appreciated
Thanks in advance
rogers42If you're using SQL*Plus
SQL> set autotrace traceonly
SQL> set timing on
SQL> <<your query here>>SQL*Plus will fetch all the data and then report the query plan, execution statistics, and elapsed time. It will not display the actual data.
SET TIMING ON alone tells SQL*Plus to display the execution time of each SQL statement-- the problem is that it also displays all the data which can skew the results because you're including the time required by SQL*Plus to pipe a bunch of data to the screen.
Justin -
How to reduce execution time of SQL Query
hi ,
i'm working on oracle ERP application i wanna to create an OAF page that shows some data on tables .
i've wirte the query but it take long time . .
any body can help :
SELECT *
FROM (SELECT person_id,
transaction_id,
segment1 AS TA_number,
segment9 AS Travel_Distination,
SUBSTR (segment5, 0, 10) AS Travel_Date,
creation_date AS request_date,
status,
full_name AS Current_Approver
FROM ( (SELECT PPF.PERSON_ID,
ht.TRANSACTION_ID,
pac.segment1,
pac.segment2,
pac.segment3,
pac.segment4,
pac.segment5,
pac.segment6,
pac.segment7,
pac.segment8,
pac.segment9,
pac.creation_date,
DECODE (al.approval_status,
NULL, 'Pending For Approval',
'APPROVE', 'Finally Approved',
al.approval_status)
status,
al.order_number,
almin.order_number approver_order,
ppf2.full_name
FROM HR_API_TRANSACTION_Values htv,
HR_API_TRANSACTIONS ht,
HR_API_TRANSACTION_STEPS hts,
PER_ANALYSIS_CRITERIA pac,
hr.Ame_Approvals_History ah,
per_people_f ppf,
per_people_f ppf2,
apps.fnd_user fu,
apps.AME_TEMP_OLD_APPROVER_LISTS al,
apps.AME_TEMP_OLD_APPROVER_LISTS almin
WHERE al.application_id = '-81'
AND al.transaction_id = ht.TRANSACTION_ID
AND (al.approval_status NOT LIKE '%REP%'
OR al.approval_status IS NULL)
AND al.order_number =
(SELECT MAX (ao.order_number)
FROM apps.AME_TEMP_OLD_APPROVER_LISTS ao
WHERE ao.transaction_id =
ht.TRANSACTION_ID
AND (ao.approval_status NOT LIKE
'%REP%'
OR ao.approval_status IS NULL))
AND ht.creator_person_id = PPF.PERSON_ID
AND ht.TRANSACTION_ID = ah.transaction_id
AND HT.TRANSACTION_ID = HTS.TRANSACTION_ID
AND fu.employee_id = PPF2.person_id
AND almin.order_number =
(SELECT MIN (aomin.order_number)
FROM apps.AME_TEMP_OLD_APPROVER_LISTS aomin
WHERE aomin.transaction_id =
ht.TRANSACTION_ID
AND aomin.approval_status IS NULL)
AND almin.transaction_id = ht.TRANSACTION_ID
AND almin.name = fu.user_name
AND hts.TRANSACTION_STEP_ID =
HTV.TRANSACTION_STEP_ID
AND HTV.NAME = 'P_ANALYSIS_CRITERIA_ID'
AND HTV.NUMBER_VALUE =
PAC.ANALYSIS_CRITERIA_ID
AND SYSDATE BETWEEN ppf.effective_start_date
AND ppf.effective_end_date
AND PROCESS_NAME = 'TA_AEC')
UNION
(SELECT PPF.PERSON_ID,
ht.TRANSACTION_ID,
pac.segment1,
pac.segment2,
pac.segment3,
pac.segment4,
pac.segment5,
pac.segment6,
pac.segment7,
pac.segment8,
pac.segment9,
pac.creation_date,
DECODE (al.approval_status,
NULL, 'Pending For Approval',
'APPROVE', 'Finally Approved',
al.approval_status)
status,
al.order_number,
al.order_number AS approver_order,
'' AS name
FROM HR_API_TRANSACTION_Values htv,
HR_API_TRANSACTIONS ht,
HR_API_TRANSACTION_STEPS hts,
PER_ANALYSIS_CRITERIA pac,
hr.Ame_Approvals_History ah,
per_people_f ppf,
per_people_f ppf2,
apps.fnd_user fu,
apps.AME_TEMP_OLD_APPROVER_LISTS al,
apps.AME_TEMP_OLD_APPROVER_LISTS almin
WHERE al.application_id = '-81'
AND al.approval_status IS NOT NULL
AND al.transaction_id = ht.TRANSACTION_ID
AND ht.creator_person_id = PPF.PERSON_ID
AND ht.TRANSACTION_ID = ah.transaction_id
AND HT.TRANSACTION_ID = HTS.TRANSACTION_ID
AND PROCESS_NAME = 'TA_AEC'
AND fu.employee_id = PPF2.person_id
AND al.order_number =
(SELECT MAX (ao.order_number)
FROM apps.AME_TEMP_OLD_APPROVER_LISTS ao
WHERE ao.transaction_id =
ht.TRANSACTION_ID
AND (ao.approval_status NOT LIKE
'%REP%'
OR ao.approval_status IS NULL))
AND al.name = fu.user_name
AND almin.transaction_id = ht.TRANSACTION_ID
AND hts.TRANSACTION_STEP_ID =
HTV.TRANSACTION_STEP_ID
AND HTV.NAME = 'P_ANALYSIS_CRITERIA_ID'
AND HTV.NUMBER_VALUE = PAC.ANALYSIS_CRITERIA_ID
AND SYSDATE BETWEEN ppf.effective_start_date
AND ppf.effective_end_date
AND PROCESS_NAME = 'TA_AEC'))) QRSLT
WHERE (person_id = 26773)
ORDER BY request_date DESCsee also this . .
Optimizer Environment (10053)
# Is
Default Parameter Current
Value
1 N _sort_elimination_cost_ratio 5
2 N _pga_max_size 838860 KB
3 N _b_tree_bitmap_plans false
4 N _fast_full_scan_enabled false
5 N _like_with_bind_as_equality true
6 N optimizer_secure_view_merging false
7 Y optimizer_mode_hinted false
8 Y optimizer_features_hinted 0.0.0
9 Y parallel_execution_enabled true
10 Y parallel_query_forced_dop 0
11 Y parallel_dml_forced_dop 0
12 Y parallel_ddl_forced_degree 0
13 Y parallel_ddl_forced_instances 0
14 Y _query_rewrite_fudge 90
15 Y optimizer_features_enable 10.2.0.4
16 Y _optimizer_search_limit 5
17 Y cpu_count 4
18 Y active_instance_count 1
19 Y parallel_threads_per_cpu 2
20 Y hash_area_size 131072
21 Y bitmap_merge_area_size 1048576
22 Y sort_area_size 65536
23 Y sort_area_retained_size 0
24 Y _optimizer_block_size 8192
25 Y _sort_multiblock_read_count 2
26 Y _hash_multiblock_io_count 0
27 Y _db_file_optimizer_read_count 8
28 Y _optimizer_max_permutations 2000
29 Y pga_aggregate_target 4194304 KB
30 Y _query_rewrite_maxdisjunct 257
# Is
Default Parameter Current
Value
31 Y _smm_auto_min_io_size 56 KB
32 Y _smm_auto_max_io_size 248 KB
33 Y _smm_min_size 1024 KB
34 Y _smm_max_size 419430 KB
35 Y _smm_px_max_size 2097152 KB
36 Y _cpu_to_io 0
37 Y _optimizer_undo_cost_change 10.2.0.4
38 Y parallel_query_mode enabled
39 Y parallel_dml_mode disabled
40 Y parallel_ddl_mode enabled
41 Y optimizer_mode all_rows
42 Y sqlstat_enabled false
43 Y _optimizer_percent_parallel 101
44 Y _always_anti_join choose
45 Y _always_semi_join choose
46 Y _optimizer_mode_force true
47 Y _partition_view_enabled true
48 Y _always_star_transformation false
49 Y _query_rewrite_or_error false
50 Y _hash_join_enabled true
51 Y cursor_sharing exact
52 Y star_transformation_enabled false
53 Y _optimizer_cost_model choose
54 Y _new_sort_cost_estimate true
55 Y _complex_view_merging true
56 Y _unnest_subquery true
57 Y _eliminate_common_subexpr true
58 Y _pred_move_around true
59 Y _convert_set_to_join false
60 Y _push_join_predicate true
# Is
Default Parameter Current
Value
61 Y _push_join_union_view true
62 Y _optim_enhance_nnull_detection true
63 Y _parallel_broadcast_enabled true
64 Y _px_broadcast_fudge_factor 100
65 Y _ordered_nested_loop true
66 Y _no_or_expansion false
67 Y optimizer_index_cost_adj 100
68 Y optimizer_index_caching 0
69 Y _system_index_caching 0
70 Y _disable_datalayer_sampling false
71 Y query_rewrite_enabled true
72 Y query_rewrite_integrity enforced
73 Y _query_cost_rewrite true
74 Y _query_rewrite_2 true
75 Y _query_rewrite_1 true
76 Y _query_rewrite_expression true
77 Y _query_rewrite_jgmigrate true
78 Y _query_rewrite_fpc true
79 Y _query_rewrite_drj true
80 Y _full_pwise_join_enabled true
81 Y _partial_pwise_join_enabled true
82 Y _left_nested_loops_random true
83 Y _improved_row_length_enabled true
84 Y _index_join_enabled true
85 Y _enable_type_dep_selectivity true
86 Y _improved_outerjoin_card true
87 Y _optimizer_adjust_for_nulls true
88 Y _optimizer_degree 0
89 Y _use_column_stats_for_function true
90 Y _subquery_pruning_enabled true
# Is
Default Parameter Current
Value
91 Y _subquery_pruning_mv_enabled false
92 Y _or_expand_nvl_predicate true
93 Y _table_scan_cost_plus_one true
94 Y _cost_equality_semi_join true
95 Y _default_non_equality_sel_check true
96 Y _new_initial_join_orders true
97 Y _oneside_colstat_for_equijoins true
98 Y _optim_peek_user_binds true
99 Y _minimal_stats_aggregation true
100 Y _force_temptables_for_gsets false
101 Y workarea_size_policy auto
102 Y _smm_auto_cost_enabled true
103 Y _gs_anti_semi_join_allowed true
104 Y _optim_new_default_join_sel true
105 Y optimizer_dynamic_sampling 2
106 Y _pre_rewrite_push_pred true
107 Y _optimizer_new_join_card_computation true
108 Y _union_rewrite_for_gs yes_gset_mvs
109 Y _generalized_pruning_enabled true
110 Y _optim_adjust_for_part_skews true
111 Y _force_datefold_trunc false
112 Y statistics_level typical
113 Y _optimizer_system_stats_usage true
114 Y skip_unusable_indexes true
115 Y _remove_aggr_subquery true
116 Y _optimizer_push_down_distinct 0
117 Y _dml_monitoring_enabled true
118 Y _optimizer_undo_changes false
119 Y _predicate_elimination_enabled true
120 Y _nested_loop_fudge 100
# Is
Default Parameter Current
Value
121 Y _project_view_columns true
122 Y _local_communication_costing_enabled true
123 Y _local_communication_ratio 50
124 Y _query_rewrite_vop_cleanup true
125 Y _slave_mapping_enabled true
126 Y _optimizer_cost_based_transformation linear
127 Y _optimizer_mjc_enabled true
128 Y _right_outer_hash_enable true
129 Y _spr_push_pred_refspr true
130 Y _optimizer_cache_stats false
131 Y _optimizer_cbqt_factor 50
132 Y _optimizer_squ_bottomup true
133 Y _fic_area_size 131072
134 Y _optimizer_skip_scan_enabled true
135 Y _optimizer_cost_filter_pred false
136 Y _optimizer_sortmerge_join_enabled true
137 Y _optimizer_join_sel_sanity_check true
138 Y _mmv_query_rewrite_enabled true
139 Y _bt_mmv_query_rewrite_enabled true
140 Y _add_stale_mv_to_dependency_list true
141 Y _distinct_view_unnesting false
142 Y _optimizer_dim_subq_join_sel true
143 Y _optimizer_disable_strans_sanity_checks 0
144 Y _optimizer_compute_index_stats true
145 Y _push_join_union_view2 true
146 Y _optimizer_ignore_hints false
147 Y _optimizer_random_plan 0
148 Y _query_rewrite_setopgrw_enable true
149 Y _optimizer_correct_sq_selectivity true
150 Y _disable_function_based_index false
# Is
Default Parameter Current
Value
151 Y _optimizer_join_order_control 3
152 Y _optimizer_cartesian_enabled true
153 Y _optimizer_starplan_enabled true
154 Y _extended_pruning_enabled true
155 Y _optimizer_push_pred_cost_based true
156 Y _sql_model_unfold_forloops run_time
157 Y _enable_dml_lock_escalation false
158 Y _bloom_filter_enabled true
159 Y _update_bji_ipdml_enabled 0
160 Y _optimizer_extended_cursor_sharing udo
161 Y _dm_max_shared_pool_pct 1
162 Y _optimizer_cost_hjsmj_multimatch true
163 Y _optimizer_transitivity_retain true
164 Y _px_pwg_enabled true
165 Y _optimizer_join_elimination_enabled true
166 Y flashback_table_rpi non_fbt
167 Y _optimizer_cbqt_no_size_restriction true
168 Y _optimizer_enhanced_filter_push true
169 Y _optimizer_filter_pred_pullup true
170 Y _rowsrc_trace_level 0
171 Y _simple_view_merging true
172 Y _optimizer_rownum_pred_based_fkr true
173 Y _optimizer_better_inlist_costing all
174 Y _optimizer_self_induced_cache_cost false
175 Y _optimizer_min_cache_blocks 10
176 Y _optimizer_or_expansion depth
177 Y _optimizer_order_by_elimination_enabled true
178 Y _optimizer_outer_to_anti_enabled true
179 Y _selfjoin_mv_duplicates true
180 Y _dimension_skip_null true
# Is
Default Parameter Current
Value
181 Y _force_rewrite_enable false
182 Y _optimizer_star_tran_in_with_clause true
183 Y _optimizer_complex_pred_selectivity true
184 Y _optimizer_connect_by_cost_based true
185 Y _gby_hash_aggregation_enabled true
186 Y _globalindex_pnum_filter_enabled true
187 Y _fix_control_key 0
188 Y _optimizer_skip_scan_guess false
189 Y _enable_row_shipping false
190 Y _row_shipping_threshold 80
191 Y _row_shipping_explain false
192 Y _optimizer_rownum_bind_default 10
193 Y _first_k_rows_dynamic_proration true
194 Y _px_ual_serial_input true
195 Y _optimizer_native_full_outer_join off
196 Y _optimizer_star_trans_min_cost 0
197 Y _optimizer_star_trans_min_ratio 0
198 Y _optimizer_fkr_index_cost_bias 10
199 Y _optimizer_connect_by_combine_sw true
200 Y _optimizer_use_subheap true
201 Y _optimizer_or_expansion_subheap true
202 Y _optimizer_sortmerge_join_inequality true
203 Y _optimizer_use_histograms true
204 Y _optimizer_enable_density_improvements false -
Is it possible to limit the execution time for a query?
I have an application that will run a query to gather statistics. The time window is defined by the user. Since the polling period for data collection varies, it is not possible to say that a large time window will result in a large resultSet. I may have a polling period of 1 minute or a polling period of 1 hour.
I want to avoid a user executing a query that will consume too many resources and inpact the system's performce in general. Could I stop a query after it takes more that x secs? Is there a way to write an sql statement indicating the max response time? similar to rownum?You can also create an Oracle profile with limited resources and assign it to the Oracle account running the queries (this profile will be used for all queries run by the corresponding user). Resources can only specifed in cpu time (not elapsed time) or logical reads.
See http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96521/users.htm#15451
and http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_611a.htm#2065932 -
Huge difference in Execution time in same Query with different Parameter
Hi Experts,
We are facing an unique problem once we are executing the query in HANA SQL prompt. This Query was generated from BObj and executing in HANA system. Once this query running with following condition, it is taking almost 7-00 minute to execute and returning around 924 rows.
<< WHERE
Table__1."LOGSYS" IN ('RKGCLNT102')
AND
Table__1."CompanyCode" IN ('7240','7245')
AND
Table__1."Plant" IN ……………… >
However if we run the same query with some different plant, It is taking only 2 second. Please find the Query here.
<< WHERE
Table__1."LOGSYS" IN ('RKGCLNT102')
AND
Table__1."CompanyCode" IN ('7245','7600')
AND
Table__1."Plant" IN ……………… >
This is really an unexpected behavior and we are not able to get the actual reason why it is behaving like this.
Could anyone please help to analyze this issue to fine the root cause.
Thanks in Advance.
Regards
Satrajit.Hi there
Unfortunately you provided too few information to analyze the issue.
Maybe the underlying tables have very skew data and the first select has to read a larger share of the base tables.
Maybe the columns had been unloaded before and the first query had to load them into memory first.
Is the runtime always bad with the one and always good with the other set of parameters?
Have you checked the PlanViz for both versions? How do these differ?
- Lars -
Execution time of query with high variance
I have an Oracle Database 11.2 R2 which is set up just for testing purposes, so there is no other activity except mine. Now I have a query which I ran 10 times in a row. Between the executions I always flushed BUFFER_CACHE and SHARED_POOL. The strange thing is, that the execution time of the query is strongly varying from 13 seconds up to 207 seconds. From the 10 executions I have 4 times <25 seconds and 4 times > 120 seconds.
What could be the reason for this? As I've said, there is no other activity on the database and it is always the same query with the same parameters running on the same set of data.
The background to this is that I would like to compare the execution time of exactly the same query with different database settings. So I thought I could just run the query ten times and use the average but I didn't expect such a high variance.
Kind regards
PeterHi,
for each execution, look at:
1) plan hash value
2) total logical I/O
3) physical I/O
That should give you some clues as to what's going on.
Best regards,
Nikolay -
Oracle View that stores the Query execution time
Hi Gurus
i m using Oracle 10G in Unix. I wudiold like to know which Data dictionary view stores the execution of a query. If it is not stored then hw to find the query execution time other than (Set timing on) command. What is the use of elapsed time and what is the difference between execution time and elapsed time? How to calculate the execution time of a query.
THanks
RamIf you have a specific query you're going to run in SQL*Plus, just do
a 'set timing on' before you execute the query.
If you've got application SQL coming in from all over the place, you can
identify specific SQL in V$SQL/ and look at ELAPSED_TIME/EXECUTIONS
to get an average elapsed time.
If you've got an application running SQL, and you need to know the
specific timing of a specific execution (as opposed to an average),
you can use DBMS_SUPPORT to set trace in the session that your
application is running in, and then use TkProf to process the resulting
trace file. -
How to get the query execution time
Hi,
I am new to oracle and I am trying to get the execution time of a query.I tried the command set timing on and executed the query.But,the time it gives me is including the display of results.In my case,I ran a query against 50 million records and it is taking around 5 hours to display all the results.I like to know,how much time it take just to execute the query?Please help.
Thanks
Ravi.Maybe this way ?
TEST@db102 SQL> set timing on
TEST@db102 SQL> set autotrace traceonly
TEST@db102 SQL> select * from foo;
332944 rows selected.
Elapsed: 00:00:29.04
Execution Plan
Plan hash value: 1245013993
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 274K| 46M| 1071 (5)| 00:00:13 |
| 1 | TABLE ACCESS FULL| FOO | 274K| 46M| 1071 (5)| 00:00:13 |
Note
- dynamic sampling used for this statement
Statistics
288 recursive calls
0 db block gets
26570 consistent gets
4975 physical reads
0 redo size
35834383 bytes sent via SQL*Net to client
244537 bytes received via SQL*Net from client
22198 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
332944 rows processed
TEST@db102 SQL> -
One space changes query execution time significantly. Why?
Hello,
my application works on Oracle DB 10.2. Today it started "hanging" on one a select query, which earlier took 1-2 seconds to execute (I waited for several minutes and then stopped it). The query is executed, using the following code:
PreparedStatement pst = conn.prepareStatement("select ... ? ... ? ... ? ");
pst.setInt(1, ...);
pst.setString(2, ...);
pst.setInt(3, ...);
ResustSet rs = pst.executeQuery();
So, it started hanging on the executeQuery() method call.
I started experimenting and discovered, that any minimal change to the query (for example, adding 1 adjacent space to the space that is already present) has the result, that query executes in 1-2 seconds again! But if I remove this additional unnecessary space - the query hangs again. This was reproduced with both web application and console application. Computing statistics didn't help.
Several hours later without any interference everything became OK - execution time of that query became 1-2 seconds. But for some time the system was, in fact, unavailable. Why could it happen, how 1 space could make such a great difference and how to prevent this situation in the future?As others already mentioned you might have a problem where for some unknown reason the execution plan changes from fast to bad.
A completely different idea would be to rewrite the statement, maybe it is possible to find a way where you allways get good plans.
For example I'm not sure if the subquery is needed. If it is then better use alias names inside the subquery too.
Suggestion
select distinct vv.vv_id, vv.value, vv.vocabs_voc_id, vv.com, vv.status, vv.code,
vv.main_vv_id, vt.vocabs_tree_node_id as node_id
from vocs_values vv left join vt_vv vt
on vv.vv_id = vt.vocs_values_vv_id
connect by prior vv.main_vv_id = vv.vv_id
start with (vv.vocabs_voc_id = ?
and upper(vv.value) like ?
and vv.status = ? ); When looking in more detail I see that you alread used an alias from the outer query inside the subquery. Is this correct?
I added some other aliases in blue for the subquery to show you the difference.
Problem?
select distinct vv.vv_id, vv.value, vv.vocabs_voc_id, vv.com, vv.status, vv.code,
vv.main_vv_id, vt.vocabs_tree_node_id as node_id
from vocs_values vv left join vt_vv vt
on vv.vv_id = vt.vocs_values_vv_id
connect by prior vv.main_vv_id = vv.vv_id
start with vv.vv_id in (select {color:blue}vv2.{color}vv_id
from vocs_values {color:blue}vv2{color}
where {color:blue}vv2.{color}vocabs_voc_id = ?
and upper({color:red}vv.{color}value) like ?
and {color:blue}vv2.{color}status = ? );Shouldn't you replace {color:red}vv.{color} with {color:blue}vv2.{color}?
Edited by: Sven W. on Nov 5, 2008 1:21 PM
Edited by: Sven W. on Nov 5, 2008 1:26 PM -
QUERY EXECUTION TIME OR SEARCH TIME
Hi Guys,
Is there any way in OUAF to know how much time did the server took to retrieve the records when an User enters a filter in a Query Zone.
How to know the search time. Is this stored anywhere?
Please help me kindly.
Your help will be highly appreciatedFollow the below steps,
01. Launch the application in debug mode(?debug=true)
02. Check the Global Debug check box
03. Now do the operation which executes ur query or query zone
04. Open the log file, go thru it. You will find the each and every executed queries. spot it ur query and check the time the of execution and retried result time. just subtract the times. You will get the execution time of the query. -
How to get the execution time of a Discoverer Report from qpp_stats table
Hello
by reading some threads on this forum I became aware of the information stored in eul5_qpp_stats table. I would like to know if I can use this table to determine the execution time of a worksheet. In particular it looks like the field qs_act_elap_time stores the actual elapsed time of each execution of specific worksheet: am I correct? If so, how is this value computed? What's the unit of measure? I assume it's seconds, but then I've seen that sometimes I get numbers with decimals.
For example I ran a worksheet and it took more than an hour to run, and the value I get in the qs_act_elap_time column is 2218.313.
Assuming the unit of measure was seconds than it would mean approx 37 mins. Is that the actual execution time of the query on the database? I guess the actual execution time on my Discoverer client was longer since some calculations were performed at the client level and not on the database.
I would really appreciate if you could shed some light on this topic.
Thanks and regards
GiovanniThanks a lot Rod for your prompt reply.
I agree with you about the accuracy of the data. Are you aware of any other way to track the execution times of Discoverer reports?
Thanks
Giovanni
Maybe you are looking for
-
Smartform internal_error when merging forms into 1 spool request
Hi, I have 2 smartforms - a letter and a certificate. The user has the option to print either one of these forms or both, per employee. I'm using 1 spool request. As soon as I call the second smartform there is an INTERNAL_ERROR. Why does this happen
-
Will I need a converter/adapter for my Macbook Pro in Japan?
I'm currently set to study abroad in Japan, and I have a few questions about what converters/adapters I'll need. Regrettably, I need to admit I'm not very tech-savvy, making this issue a bit more complicated for me. Electricity in Japan runs at 100 v
-
Not sure why this took me to the US discussion board, so I hope I'm in the right place!! If it matters. I'm in Canada! I bought an AppleTV today. Setup was super easy (I'm listening to my iTunes library right now!) BUT .... the ONE thing I really
-
Hi Everyone Can anybody throw some light on the various time constraints used in the HR-ABAP and their relation to the infotypes. Also specify if their some Transaction code from where we can get to know about the value's of the time constraints. And
-
No preview for imported photos any more (just an hour-glass?) Elements 9 Org
up until last month my photos showed up as normal thumbnails but I must have changed something?? Anything I import into PS Elements 9 Organizer is blank, only shows an hourglass. Can someone please help?? Thanks, Jeff.