
💡

💡 LRU(Least Recent Use) 알고리즘

select sal
from emp
where ename='SCOTT';
- 인덱스 스캔 :
single block i/o가 발생 —→ MRU 로 올라감- Full table 스캔 :
multi block i/o가 발생 —> LRU 로 올라감
만약 테이블이 nocache 속성이면 위와 같이 작동합니다.
그런데 테이블이 cache 속성이면 인덱스 스캔을 하든 full table scan을 하든 모두 MRU 로 올립니다.
dba가 이 내용을 알고 있어야하는 이유 ?
답: 우리 회사에 자주 엑세스하는 작은 테이블은 테이블의 cache 속성을 nocache 가 아니라 cache로 해주면 좋은 성능을 보입니다.
select table_name, cache
from user_tables;

alter table emp cache;
select table_name, cache
from user_tables;
alter table emp nocache;
select /*+ cache */ sal
from emp
where ename='SCOTT';
- nocache : index scan 을 하면 MRU 로 블럭을 올리고
full table scan 을 하게 되면 LRU 쪽에 블럭을 올리는 속성- cache : index scan 을 하든 full table scan 을 하든 모두 MRU 로 올리는 속성
답: 작고 자주 엑세스하는 테이블
alter table hr.employees cache;
alter table hr.countries cache;
alter table hr.regions cache;
alter table hr.locations cache;
alter table hr.departments cache;
alter table hr.jobs cache;
alter table hr.job_history cache;
select table_name, cache
from dba_tables
where owner='HR';