Sie sind auf Seite 1von 6

Hi,

can someone tell me if it is possible to determine how many times


a query was executed in a database. If so, how can I go about
finding out this information.

Regards,
Oraclelearner

Nov 6 2008, 01:43 PM


SteveC
Post #2
Which version of Oracle?

Advanced Member You can use statspack and count the executions.

Group: Members
Posts: 2,112
Joined: 11-March 08
Member No.: 18,933

Nov 6 2008, 03:09 PM


Oraclelearner
Post #3
QUOTE (SteveC @ Nov 6 2008, 11:44 AM)
Which version of Oracle?
Advanced Member
You can use statspack and count the executions.
Group: Members
Posts: 152
Hi Steve,
Joined: 6-May 08
From: 99324
I'm using Oracle version 10g. I was hoping there was a way to
Member No.: 22,933
gather this information through Oracle 10g Grid Control.

Regards,
Oraclelearner

Nov 6 2008, 05:08 PM


burleson
Post #4
>> I was hoping there was a way to gather this information
through Oracle 10g Grid Control.

That's just a GUI into the Oracle tables, a tool for newbies . . . .

*****************************************************
*******
Advanced Member
>> it is possible to determine how many times a query was
executed in a database. If
Group: Members
Posts: 8,534 Between bounces, see the execitions column of v$sql.
Joined: 26-January 04
Member No.: 13 Long term, you can use dba_hist_sqlstat to track SQL executions
over time:

http://www.dba-oracle.com/t_time_series_sq...ce_tracking.htm

CODE
select
p.sql_id c1,
p.cost c2,
to_char(s.sql_text) c3
from
dba_hist_sql_plan p,
dba_hist_sqltext s
where . . .

But you can use these ONLY IF you have a license for the AWR
tables. Oracle Database Diagnostic Pack is a $3000 extra-cost
option, and you must have a license to access the Oracle10g
AWR and ADDM components.

--------------------
Hope this helps. . .

Donald K. Burleson
Oracle Press author
Author of Oracle Tuning: The Definitive Reference

Nov 6 2008, 05:19 PM


Oraclelearner
Post #5
QUOTE (burleson @ Nov 6 2008, 02:09 PM)
>> I was hoping there was a way to gather this information
Advanced Member through Oracle 10g Grid Control.

That's just a GUI into the Oracle tables, a tool for newbies . . . .
Group: Members
Posts: 152
Joined: 6-May 08
*****************************************************
From: 99324
*******
Member No.: 22,933
>> it is possible to determine how many times a query was
executed in a database. If

Between bounces, see the execitions column of v$sql.

Long term, you can use dba_hist_sqlstat to track SQL executions


over time:

http://www.dba-oracle.com/t_time_series_sq...ce_tracking.htm

CODE
select
p.sql_id c1,
p.cost c2,
to_char(s.sql_text) c3
from
dba_hist_sql_plan p,
dba_hist_sqltext s
where . . .

But you can use these ONLY IF you have a license for the AWR
tables. Oracle Database Diagnostic Pack is a $3000 extra-cost
option, and you must have a license to access the Oracle10g
AWR and ADDM components.

Thank you Mr. Burleson!

Nov 6 2008, 07:02 PM


burleson
Post #6
Hi Steve,

>> You can use statspack and count the executions.

But how to you identify the same SQL ID between snapshots


and bounces?
Advanced Member --------------------
Hope this helps. . .
Group: Members
Posts: 8,534 Donald K. Burleson
Joined: 26-January 04 Oracle Press author
Member No.: 13 Author of Oracle Tuning: The Definitive Reference

Nov 6 2008, 07:44 PM


SteveC
Post #7
I believe he is looking for the statement, not the ID. The SQL
ordered by Gets shows the statements encountered during the
Advanced Member period in question. Under the Executions column = number of
times called.
Group: Members
Could also cross reference hash value, text_subset, piece and
Posts: 2,112
sql_text in stats$sqltext. If the statement is longer than what is
Joined: 11-March 08
shown in the report, then the cross reference hack job can be
Member No.: 18,933
employed. Tedious, but doable.

SQL Query History Reply


Posted: 11-jun-2008 6:11
Hi everybody,

My application is running for the past two months. My job is to improve its
performance by tuning the SQL queries it issues to the db. For that, I need to find out
those queries which are taking more time and resource.

I have looked into WRH$_HIST_SQLSTAT, WRH$_HIST_SQLTEXT,


V$_SESSION, and V$SQL but did'nt find all of them. Are there any other tables where
I find these queries? Does the ADDM record all the queries issuerd by my application
into WRH$ tables ?
damorgan Re: SQL Query History Reply
Posted: 11-jun-2008 6:17 in response to:
Posts: 12,352 ice_cold_aswin
Registered: 10/20/03 Assuming you have the proper licensing in place look in
GV$ACTIVE_SESSION_HISTORY.
Aman.... Re: SQL Query History Reply
Posted: 11-jun-2008 6:36 in response to:
Posts: 14,252 ice_cold_aswin
Registered: 05/20/01 Aswin,
Are you looking for the queries since last 2 months and trying to
tune them or you have some query in your hand at the moment
which you are trying to optimize?If its historical query than it
wont be there as the AWR repository is not kept for that long.By
default the purge is done on every 7th day.So if you are looking
for 2 month old queries, there are none at the moment.
If you are trying to tune the currently used queries, Daniel has
given you a good start.Try looking at that and also get one AWR
report to see the statements which may come as an candiate for
tuning.
That said, before starting,make sure you have a benchmark to
tune those "unoptimized queries".Many times I have seen people
are "just not happy with the query" though the query with the
given statement,resources is doing reasonably well.
Aman....
Gaff Re: SQL Query History Reply
Posted: 11-jun-2008 8:36 in response to:
Posts: 1,013 ice_cold_aswin
Registered: 10/30/02 Hi:

You don't say what version of Oracle you are using, but if it is
10g or 11g then you can more easily make use of the tables that
have always been in Oracle that are used to examine these
performance related issues by using Oracle Enterprise Manager.
OEM will let you see exactly the kinds of things you've been
asking about. It won't necessarily go back 2 months but you can
either use the history it does keep to identify the trouble areas or
you can start taking snapshots on a regular basis for the next two
months and work from there. I'd start with using the history it
does keep.

Good luck.
SQL Query History Reply
Posted: 11-jun-2008 6:11
Hi everybody,

My application is running for the past two months. My job is to improve its
performance by tuning the SQL queries it issues to the db. For that, I need to find out
those queries which are taking more time and resource.

I have looked into WRH$_HIST_SQLSTAT, WRH$_HIST_SQLTEXT,


V$_SESSION, and V$SQL but did'nt find all of them. Are there any other tables where
I find these queries? Does the ADDM record all the queries issuerd by my application
into WRH$ tables ?
damorgan Re: SQL Query History Reply
Posted: 11-jun-2008 6:17 in response to:
Posts: 12,352 ice_cold_aswin
Registered: 10/20/03 Assuming you have the proper licensing in place look in
GV$ACTIVE_SESSION_HISTORY.
Aman.... Re: SQL Query History Reply
Posted: 11-jun-2008 6:36 in response to:
Posts: 14,252 ice_cold_aswin
Registered: 05/20/01 Aswin,
Are you looking for the queries since last 2 months and trying to
tune them or you have some query in your hand at the moment
which you are trying to optimize?If its historical query than it
wont be there as the AWR repository is not kept for that long.By
default the purge is done on every 7th day.So if you are looking
for 2 month old queries, there are none at the moment.
If you are trying to tune the currently used queries, Daniel has
given you a good start.Try looking at that and also get one AWR
report to see the statements which may come as an candiate for
tuning.
That said, before starting,make sure you have a benchmark to
tune those "unoptimized queries".Many times I have seen people
are "just not happy with the query" though the query with the
given statement,resources is doing reasonably well.
Aman....
Gaff Re: SQL Query History Reply
Posted: 11-jun-2008 8:36 in response to:
Posts: 1,013 ice_cold_aswin
Registered: 10/30/02 Hi:

You don't say what version of Oracle you are using, but if it is
10g or 11g then you can more easily make use of the tables that
have always been in Oracle that are used to examine these
performance related issues by using Oracle Enterprise Manager.
OEM will let you see exactly the kinds of things you've been
asking about. It won't necessarily go back 2 months but you can
either use the history it does keep to identify the trouble areas or
you can start taking snapshots on a regular basis for the next two
months and work from there. I'd start with using the history it
does keep.

Good luck.

Das könnte Ihnen auch gefallen