深入理解Oracle索引(7):用实验数据观察从B-tree索引→复合索引→Bitmap索引所消费的CPU和I/O
环境:
sh@ORCL> set autot offsh@ORCL> select index_name from user_indexes where table_name='CUSTOMERS';INDEX_NAME------------------------------IDX_CUST_GEN_POS_CREDCUSTOMERS_PKsh@ORCL> drop index IDX_CUST_GEN_POS_CRED;Index dropped.sh@ORCL> create bitmap index idx_cust_gender on customers(cust_gender);Index created.sh@ORCL> create bitmap index idx_cust_postal_code on customers (cust_postal_code);Index created.sh@ORCL> create bitmap index idx_cust_credit_limit on customers(cust_credit_limit);Index created.sh@ORCL> edWrote file afiedt.buf 1 select c.* 2 from customers c 3 where cust_gender = 'M' and 4 cust_postal_code = '40804' and 5* cust_credit_limit = 10000 6 sh@ORCL> /6 rows selected.Execution Plan----------------------Plan hash value: 724066067------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |------------------------------------------------------------------| 0 | SELECT STATEMENT | | 6 | 1080 | 4 (0)| 00:00:01 || 1 | TABLE ACCESS BY INDEX ROWID | CUSTOMERS | 6 | 1080 | 4 (0)| 00:00:01 || 2 | BITMAP CONVERSION TO ROWIDS| | | | | || 3 | BITMAP AND | | | | | ||* 4 | BITMAP INDEX SINGLE VALUE| IDX_CUST_POSTAL_CODE | | | | ||* 5 | BITMAP INDEX SINGLE VALUE| IDX_CUST_CREDIT_LIMIT | | | | ||* 6 | BITMAP INDEX SINGLE VALUE| IDX_CUST_GENDER | | | | |------------------------------------------------------------------Predicate Information (identified by operation id):--------------------------------------------------- 4 - access("CUST_POSTAL_CODE"='40804') 5 - access("CUST_CREDIT_LIMIT"=10000) 6 - access("CUST_GENDER"='M')Statistics---------------------- 0 recursive calls 0 db block gets 15 consistent gets 0 physical reads 0 redo size 2974 bytes sent via SQL*Net to client 385 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 6 rows processedCost:8
逻辑读:15