-
Notifications
You must be signed in to change notification settings - Fork 849
/
Copy path03_hll.sql
63 lines (51 loc) · 1.68 KB
/
03_hll.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
61
62
63
--
-- Create some test tables
-- NOTE!
-- Tables called T1 and EXCH will be dropped
--
set echo on
set timing on
set linesize 1000
set pagesize 100
set trims on
column partition_name format a40
column ndv_alg format a30
column inc_stale format a30
drop table t1 purge;
create table t1 (id number(10),num1 number(10), num2 number(10),txt varchar2(20))
partition by range (num1)
interval (1) (
partition p1 values less than (1)
,partition p2 values less than (2));
insert /*+ APPEND */ into t1
select rownum, mod(rownum,5), mod(rownum,1000),'X'||mod(rownum,10000)
from (select 1 from dual connect by level <=1000);
commit;
--
-- Enable incremental statistics
--
exec dbms_stats.set_table_prefs(null,'t1','incremental','true')
--
-- Disalow mixed format
--
exec dbms_stats.set_table_prefs(null,'t1', 'incremental_staleness', 'NULL')
--
-- Create old-style synopses
--
exec dbms_stats.set_table_prefs(null,'t1', 'approximate_ndv_algorithm', 'adaptive sampling')
exec dbms_stats.gather_table_stats(null,'t1')
select dbms_stats.get_prefs('approximate_ndv_algorithm',user,'t1') ndv_alg from dual;
select dbms_stats.get_prefs('incremental_staleness',user,'t1') inc_stale from dual;
@t1check
--
-- Add a new partition and don't make any others stale
--
insert /*+ APPEND */ into t1
select rownum, 5, mod(rownum,1000),'X'||mod(rownum,10000)
from (select 1 from dual connect by level <=1000);
@t1check
exec dbms_stats.set_table_prefs(null,'t1', 'approximate_ndv_algorithm', 'hyperloglog')
select dbms_stats.get_prefs('approximate_ndv_algorithm',user,'t1') ndv_alg from dual;
select dbms_stats.get_prefs('incremental_staleness',user,'t1') inc_stale from dual;
exec dbms_stats.gather_table_stats(null,'t1')
@t1check