Oracle 기본정리 - 인덱스(Index)
프로그래밍 정리/Oracle
2019. 12. 4. 13:10
반응형
Oracle 기본정리 - 인덱스(Index)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | -------------------------------------------------------인덱스----------------------------------------------------------- --인덱스 전체 테이블 desc user_indexes; select index_name, index_type, table_owner, table_name,table_type from user_indexes; --인덱스 컬럼 전체 테이블 desc user_ind_columns; select index_name, table_name, column_name from user_ind_columns; ----------------------------------------------- --인덱스 속도 측정 해보기 --예제1. 인덱스가 없을경우 속도 --테이블 복사 create table emp02 as select * from emp; --테이블 150만개 복사 insert into emp02 select * from emp02; --튜플 추가 insert into emp02(empno,ename) values(1111,'hong'); --해당 튜플 검색 => 인출 시간 0.406초 select distinct empno,ename from emp02 where ename='hong'; ----------------------------------- --예제2 인덱스 있을경우 --인덱스 생성 create index index_emp02_ename on emp02(ename); --해당 튜플 검색 => 인출 시간 0초 select distinct empno,ename from emp02; ----------------------------------- --인덱스 삭제 drop index index_emp02_ename; --------------------------------------- --인덱스 사용해야하는 경우 1.행수가 많을때 2. where문에 해당 컬럼이 많이 사용될때 3.전체 데이터 중 2%~3%를 사용할때 4. null을 포함하는 컬럼이 많을 경우 --인덱스 사용하지 말아야 하는 경우 1.행수가 적을때 2. where문에 해당 컬럼이 자주 사용되지 않을때 3. 전체 데이터 중 10%~20% 이상 사용할때 4. dml 작업이 많은 경우 --------------------------------------- --문제1 인덱스를 걸어보아라 select INDEX_NAME, TABLE_NAME, COLUMN_NAME from user_ind_columns where table_name in('EMP02'); create index idx_emp02_job on emp02(job); select * from user_ind_columns where table_name = 'EMP02'; | cs |
반응형
'프로그래밍 정리 > Oracle' 카테고리의 다른 글
Oracle 기본정리 - Declare, Procedure 문제 (0) | 2019.12.04 |
---|---|
Oracle 기본정리 - Declare, Procedure 기본 (0) | 2019.12.04 |
Oracle 기본정리 - 시퀀스(sequence) (0) | 2019.12.04 |
Oracle 기본정리 - view (0) | 2019.12.04 |
Oracle 기본정리 - 외래키, 제약조건 (0) | 2019.12.04 |