Skip to content

Commit

Permalink
make tab
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelbayliss committed Oct 2, 2018
1 parent e2755f2 commit cb28861
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions optimizer/first_rows/README.md
Expand Up @@ -4,6 +4,8 @@ It improves the costing of FIRST ROWS type queries so that the optimizer makes b

This is important for applications that return rows (in sorted order) to users that paginate through the result set.

Create the table with make_tab.sql

See scripts before.sql and after.sql - spooled 'lst' output files are provided.

Compare the cost in the before and after versions, and also compare the differences in the resulting plans. The costs in the *after* example (for FETCH FIRST) are much lower and compare favorably with the ROWNUM queries.
Expand Down
14 changes: 14 additions & 0 deletions optimizer/first_rows/make_tab.sql
@@ -0,0 +1,14 @@
drop table t purge;

create table t nologging as
select d.* from dba_objects d,
( select 1 from dual connect by level <= 10 )
where object_id is not null;

alter table t noparallel;

alter table t modify object_id not null;

create index ix on t ( object_id ) ;

exec dbms_stats.gather_table_stats(user,'t')

0 comments on commit cb28861

Please sign in to comment.