code_junkie

SQL/Oracle: when indexes on multiple columns can be used

Nov 10th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. create table mytab nologging as (
  2. select mod(rownum, 3) x, rownum y, mod(rownum, 3) z from all_objects, (select 'x' from user_tables where rownum < 4)
  3. );
  4.  
  5. create index i on mytab (x, y, z);
  6.  
  7. exec dbms_stats.gather_table_stats(ownname=>'DBADMIN',tabname=>'MYTAB', cascade=>true);
  8.  
  9. set autot trace exp
  10.  
  11. select * from mytab where y=5000;
  12.  
  13. Execution Plan
  14. ----------------------------------------------------------
  15. 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=10)
  16. 1 0 INDEX (SKIP SCAN) OF 'I' (INDEX) (Cost=1 Card=1 Bytes=10)
Add Comment
Please, Sign In to add comment