rudolf@TEST902>create table t nologging 2 as 0select object_name product_name,mod(object_id,4)*10 category, 3 object_id price,rpad( a ,300, b ) supplier 4 from all_objects order by 2,1 5 /
rudolf@TEST902>create index t_category_pname_ind on t (category,product_name) 2 nologging 3 tablespace indx 4 /
Index created.
rudolf@TEST902>analyze table t compute statistics 2 for table 3 for all indexes 4 for all indexed columns 5 /
Table analyzed.
rudolf@TEST902>0select table_name,blocks,empty_blocks from user_tables where table_name = T .
TABLE_NAME BLOCKS EMPTY_BLOCKS ------------------------------ ---------- ------------ T 1039 113
为了便于讨论,我们先来看一下传统的做法:
rudolf@TEST902>0select * from 2 ( 0select rownum rnm, a.* from 3 ( 0select * from t where category = &.category_id 4 order by product_name 5 ) a 6 ) where rnm between &.minrnm and &.maxrnm 7