본문 바로가기
Oracle/아키텍쳐

Table Full Scan과 LRU 알고리즘

by 취미툰 2022. 5. 18.
반응형

Table Full Scan을 하면 LRU 알고리즘에서 LRU end(Least Recently Used)에 블록이 위치하게 되어서 사용률이 떨어진다는 이야기를 들었습니다. 

정확한 이야기가 맞는지 궁금해서 확인해보고 정리해보았습니다.

 

먼저, Table Full Scan이란?

테이블의 블록을 탐색할 때 Index를 사용하지 않고 테이블 전체를 읽는 것을 말합니다.

실행계획상에서도 Table Full Scan이라고 보여집니다.

 

LRU 알고리즘이란?

버퍼 캐시에 적용된 방식으로 자주사용되는 것은 계속 버퍼상에 위치해있고, 자주 사용하지 않는 것은 LRU 체인에서 점점 LRU end쪽으로 밀려가다가 새로운 블록이 들어와서 자리가 없을 때 LRU end끝에 있는 블록부터 밀어내는 알고리즘입니다.

 

개념은 위에 정의된 대로이고, 이제 Table Full Scan을 수행하였을 때 LRU 알고리즘에 end쪽으로 바로 위치하게 되는 것이 맞는지에 대한 것을 알아보겠습니다.

The LRU Algorithm and Full Table Scans

When the user process is performing a full table scan, it reads the blocks of the table into buffers and puts them on the LRU end (instead of the MRU end) of the LRU list. This is because a fully scanned table usually is needed only briefly, so the blocks should be moved out quickly to leave more frequently used blocks in the cache.

You can control this default behavior of blocks involved in table scans on a table-by-table basis. To specify that blocks of the table are to be placed at the MRU end of the list during a full table scan, use the CACHE clause when creating or altering a table or cluster. You can specify this behavior for small lookup tables or large static historical tables to avoid I/O on subsequent accesses of the table.

 

출처 : https://docs.oracle.com/cd/B19306_01/server.102/b14220/memory.htm

 

Memory Architecture

13/36 8 Memory Architecture This chapter discusses the memory architecture of an Oracle instance. This chapter contains the following topics: Introduction to Oracle Memory Structures Oracle uses memory to store information such as the following: Program co

docs.oracle.com

 

위의 글을 해석해보면,

유저 프로세스가 Full Table Scan을 수행하면 그 블록들은 LRU end에 위치한다라고 되어 있습니다. 이유도 나와있는데 이유는 오라클이 full table scan은 잠깐(가끔) 수행하는 것으로 판단하여 LRU 체인에 위치해 있는 다른블록들을 남겨두기 위해 그렇게 위치한다고 되어 있습니다.

 

하지만 유저가 DDL(create or alter)사용시나 cluster 테이블 사용시에 cache 절을 사용하면 블록들을 MRU end(Most Recently Used)(제일 자주 사용되는 블록들이 위치한 LRU end의 반대쪽)에 위치시킬수 있다고 합니다.

 

이로써 궁금증은 해결되었네요.

 

추후에 테스트할 기회가 있다면 cache 옵션을 사용한 테스트를 추가하겠습니다

반응형

'Oracle > 아키텍쳐' 카테고리의 다른 글

Oracle 21c 아키텍쳐  (0) 2021.01.22
오라클 기동,정지 절차  (0) 2020.06.12
Character Set 한글 테스트  (0) 2020.04.20
Character Set  (1) 2020.04.20
오라클 19c 아키텍쳐 소개  (0) 2020.03.05

댓글