oracle10g - How do I get the number of inserts/updates occuring in an Oracle database? -
how total number of inserts/updates have occurred in oracle database on period of time?
assuming you've configured awr retain data sql statements (the default retain top 30 cpu, elapsed time, etc. if statistics_level
'typical' , top 100 if statistics_level
'all') via like
begin dbms_workload_repository.modify_snapshot_settings ( topnsql => 'maximum' ); end;
and assuming sql statements don't age out of cache before snapshot captures them, can use awr tables of this.
you can gather number of times insert statement executed , number of times update statement executed
select sum( stat.executions_delta ) insert_executions dba_hist_sqlstat stat join dba_hist_sqltext txt on (stat.sql_id = txt.sql_id ) join dba_hist_snapshot snap on (stat.snap_id = snap.snap_id) snap.begin_interval_time between <<start time>> , <<end time>> , txt.command_type = 2; select sum( stat.executions_delta ) update_executions dba_hist_sqlstat stat join dba_hist_sqltext txt on (stat.sql_id = txt.sql_id ) join dba_hist_snapshot snap on (stat.snap_id = snap.snap_id) snap.begin_interval_time between <<start time>> , <<end time>> , txt.command_type = 6;
note these queries include both statements application issues , statements oracle issues in background. add additional criteria if want filter out sql statements.
similarly, total number of distinct insert , update statements
select count( distinct stat.sql_id ) distinct_insert_stmts dba_hist_sqlstat stat join dba_hist_sqltext txt on (stat.sql_id = txt.sql_id ) join dba_hist_snapshot snap on (stat.snap_id = snap.snap_id) snap.begin_interval_time between <<start time>> , <<end time>> , txt.command_type = 2; select count( distinct stat.sql_id ) distinct_update_stmts dba_hist_sqlstat stat join dba_hist_sqltext txt on (stat.sql_id = txt.sql_id ) join dba_hist_snapshot snap on (stat.snap_id = snap.snap_id) snap.begin_interval_time between <<start time>> , <<end time>> , txt.command_type = 6;
oracle not, however, track number of rows inserted or updated in given interval. won't able information awr. closest try leverage monitoring oracle determine if statistics stale. assuming monitoring
enabled each table (it default in 11g , believe default in 10g), i.e.
alter table table_name monitoring;
oracle periodically flush approximate number of rows inserted, updated, , deleted each table sys.dba_tab_modifications
table. show activity since statistics gathered on table, not activity in particular interval. could, however, try write process periodically captured data own table , report off that.
if instruct oracle flush monitoring information memory disk (otherwise there lag of several hours)
begin dbms_stats.flush_database_monitoring_info; end;
you can approximate count of number of rows have changed in each table since statistics last gathered
select table_owner, table_name, inserts, updates, deletes sys.dba_tab_modifications
Comments
Post a Comment