/
bind_peeking.sql
61 lines (35 loc) · 1.32 KB
/
bind_peeking.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
--------------------------------------------------------------------------------
--
-- File name: demos/bind_peeking.sql
--
-- Purpose: Advanced Oracle Troubleshooting Seminar demo script
--
-- Author: Tanel Poder ( http://www.tanelpoder.com )
--
-- Copyright: (c) 2007-2009 Tanel Poder
--
--------------------------------------------------------------------------------
set echo on
drop table t;
create table t as select * from dba_objects, (select rownum from dual connect by level <= 20);
create index i on t(object_id);
exec dbms_stats.gather_table_stats(user, 'T');
select count(*), min(object_id), max(object_id) from t;
pause
var x number
exec :x := 100000
pause
set timing on
select sum(length(object_name)) from t where object_id > :x;
select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
pause
exec :x := 1
select sum(length(object_name)) from t where object_id > :x;
select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
pause
select sum(length(object_name)) from t where object_id > :x;
select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
set echo off