about me:oracle ace,optimistic,passionate and harmonious. focus on oracle programming,peformance tuning,db design, j2ee,linux/aix,web2.0 tech,etc
全部博文(145)
分类: oracle
2023-04-17 16:58:53
--create table
create table test as select object_id,object_name,'file1000000000000000000000000xyz_20230215_'||rownum from dba_objects; --create index create index idx_test on test(file_id); --gather statistics exec dbms_stats.gather_table_stats(ownname=>'dingjun123',tabname=>'test',estimate_percent=>null,method_opt=>'for all columns size auto',no_invalidate=>false,cascade=>true,degree => 10); exec dbms_stats.gather_table_stats(ownname=>'dingjun123',tabname=>'test',estimate_percent=>null,method_opt=>'for columns file_id size skewonly',no_invalidate=>false,cascade=>true,degree => 10); |
select * from test where file_id='file1000000000000000000000000xyz_20230215_999';
1 row selected. elapsed: 00:00:00.01 execution plan ---------------------------------------------------------- plan hash value: 1357081020 -------------------------------------------------------------------------- | id | operation | name | rows | bytes | cost (%cpu)| time | -------------------------------------------------------------------------- | 0 | select statement | | 76815 | 5776k| 247 (1)| 00:00:03 | |* 1 | table access full| test | 76815 | 5776k| 247 (1)| 00:00:03 | -------------------------------------------------------------------------- predicate information (identified by operation id): --------------------------------------------------- 1 - filter("file_id"='file1000000000000000000000000xyz_20230215_999') statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 881 consistent gets 0 physical reads 0 redo size 742 bytes sent via sql*net to client 520 bytes received via sql*net from client 2 sql*net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed |
exec dbms_stats.gather_table_stats(ownname=>'dingjun123',tabname=>'test',estimate_percent=>null,method_opt=>'for columns file_id size 1',no_invalidate=>false,cascade=>true,degree => 10);
删除直方图后正确: execution plan ---------------------------------------------------------- plan hash value: 2473784974 ---------------------------------------------------------------------------------------- | id | operation | name | rows | bytes | cost (%cpu)| time | ---------------------------------------------------------------------------------------- | 0 | select statement | | 1 | 77 | 4 (0)| 00:00:01 | | 1 | table access by index rowid| test | 1 | 77 | 4 (0)| 00:00:01 | |* 2 | index range scan | idx_test | 1 | | 3 (0)| 00:00:01 | ---------------------------------------------------------------------------------------- predicate information (identified by operation id): --------------------------------------------------- 2 - access("file_id"='file1000000000000000000000000xyz_20230215_999') statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 5 consistent gets 0 physical reads 0 redo size 746 bytes sent via sql*net to client 520 bytes received via sql*net from client 2 sql*net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed |