Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

인덱스 작업 #138

Open
skarltjr opened this issue Nov 4, 2022 · 0 comments
Open

인덱스 작업 #138

skarltjr opened this issue Nov 4, 2022 · 0 comments
Labels

Comments

@skarltjr
Copy link
Owner

skarltjr commented Nov 4, 2022

데이터베이스의 인덱스는 b+ tree 구조를 활용한다
이때 b는 balance 즉 정렬된 상태를 유지하는데
여기서는 근간이 되는 b tree의 동작을 대상으로
인덱스 삭제, 추가 등의 작업 후 어떤 동작이 일어나는지
어떤 동작이 오버헤드가 가장 클지 생각해보자

추가

1. 추가를 위해 키 값을 저장할 노드를 탐색한다
2. 키, 값을 저장

추가의 경우 테이블에 레코드를 추가하는 작업의 부하를 1이라고 했을때 인덱스 추가는 1.5라고 볼 수 있다.
디스크로부터 인덱스 페이지를 읽고 쓰는 작업을 해야하기 때문에 큰 작업이다.
인덱스의 잦은 변경을 왜 주의해야하는지 알 수 있다.

삭제

삭제의 경우 비교적 간단하다.
키를 탐색 후 더 이상 사용하지 않는다는 마킹 작업을 한다.

변경

변경은 삭제 + 추가의 작업이다.
- 먼저 사용하지 않는 키를 마킹하고
- 새롭게 키,값을 추가한다.
즉 가장 오버헤드가 큰 작업으로 생각된다.
@skarltjr skarltjr added the Record label Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant