Skip to content

[week8] db 데이터 저장 방식#14

Open
Gusionling wants to merge 1 commit intomainfrom
week8/hyeongkyu
Open

[week8] db 데이터 저장 방식#14
Gusionling wants to merge 1 commit intomainfrom
week8/hyeongkyu

Conversation

@Gusionling
Copy link
Copy Markdown
Contributor

No description provided.

@Gusionling Gusionling self-assigned this Apr 5, 2026
Copy link
Copy Markdown
Contributor

@sunnny619 sunnny619 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

Comment thread DB/저장소와 검색.md
1. **지속성:** 전원이 꺼져도 내용이 손실되지 않는다.
2. **가격:** 기가바이트당 가격이 더 저렴하다.

근데 램이 점점 저렴해지면서 기가바이트당 가격 논쟁은 약해졌다. 데이터셋 대부분은 그다지 크지 않기 때문에 메모리에 전체를 보관하는 방식도 꽤 현실적이다. 혹은 여러 장비 간 분산해서 보관할 수도 있다. -> 이런 이유로 **인메모리 데이터베이스**가 개발됐다.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말씀해주신 내용과 달리 최근 AI 서버들이 메모리를 싹쓸이하면서 RAM 가격이 폭등했는데 설명과 달리 변화된 양상이 있나요?

Comment thread DB/저장소와 검색.md
Comment on lines +123 to +125
-> 이걸 해결하기 위해 **블룸 필터(Bloom filter)** 를 추가적으로 사용한다. 집합 내용을 근사하는(approximating) 메모리 효율적 데이터 구조로, "이 키 DB에 없음"을 미리 알려줘서 불필요한 디스크 읽기를 줄여준다.

블룸 필터는 큰 체크 박스와 같다. 특별한 해시 함수 구조로 찾고자 하는 데이터를 넣으면 이 데이터는 몇번, 몇번 부분이 체크돼야한다 라는 값이 나온다. 체크가 안 돼있다면 DB에 없는 것이다. O(1) 로 판단 가능
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

블룸 필터 설명 좋은데, False Positive는 가능하지만 False Negative는 없다는 핵심 특성만 조금 더해주면 너무 좋을거같아욤
없다고 하면 진짜 없는 거지만, 있다고 해도 실제로 없을 수 있다는 게 블룸 필터의 핵심!

Copy link
Copy Markdown
Member

@jaeunda jaeunda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

알차고 흥미로워요.. 고생하셨습니다!

Comment thread DB/저장소와 검색.md

LSM 트리의 약점이 있는데, DB에 없는 키를 찾을 때다. 멤테이블부터 가장 오래된 세그먼트까지 전부 뒤져야 하기 때문에 (디스크 읽기가 발생할 수 있음) 꽤 느릴 수 있다.

-> 이걸 해결하기 위해 **블룸 필터(Bloom filter)** 를 추가적으로 사용한다. 집합 내용을 근사하는(approximating) 메모리 효율적 데이터 구조로, "이 키 DB에 없음"을 미리 알려줘서 불필요한 디스크 읽기를 줄여준다.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

신기하다... 원리가 궁금해요..

Comment thread DB/저장소와 검색.md

B 트리가 오래된 만큼 최적화 기법도 많이 쌓여있다. 주요한 것들:

- **WAL 대신 Copy-on-write 방식**: 변경된 페이지를 다른 위치에 기록하고 상위 페이지의 새 버전을 만든다. 동시성 제어에도 유용.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COW 방식이 새 페이지에 기존 페이지 내용을 복사하고 수정한 다음 포인터를 교체하는 거라고 이해하고 있는데, 동시성 제어에 어떻게 유용한지 어떤 이점이 있는지 설명해주세욤

Comment thread DB/저장소와 검색.md

볼트DB(VoltDB), 맴SQL(MemSQL), 오라클 타임즈텐(Oracle TimesTen) 같은 제품은 관계형 모델의 인메모리 데이터베이스다. 이런 제품 벤더는 디스크 상 데이터 구조 관리와 관련된 오버헤드를 모두 없앴기 때문에 성능을 크게 개선했다고 주장한다. 램클라우드(RAMCloud)는 지속성 있는 오픈소스 인메모리 키-값 저장소로 메모리 데이터뿐 아니라 디스크 데이터도 로그 구조화 접근 방식을 사용한다. 레디스(Redis)와 카우치베이스(Couchbase)는 비동기로 디스크에 기록하기 때문에 약한 지속성을 제공한다.

근데 여기서 직관에 어긋나는 포인트가 있다. 인메모리 데이터베이스의 성능 장점이 "디스크에서 읽지 않아도 된다"는 사실 때문이 아니라는 거다. -> 심지어 디스크 기반 저장소 엔진도 운영체제가 최근에 사용한 디스크 블록을 메모리에 캐시하기 때문에 충분한 메모리를 가진 경우에는 디스크에서 읽을 필요가 없다. 오히려 인메모리 데이터 구조를 디스크에 기록하기 위한 형태로 부호화하는 오버헤드를 피할 수 있어서 더 빠른 것이다.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...!!!

Comment thread DB/저장소와 검색.md

-> 이걸 해결하기 위해 **블룸 필터(Bloom filter)** 를 추가적으로 사용한다. 집합 내용을 근사하는(approximating) 메모리 효율적 데이터 구조로, "이 키 DB에 없음"을 미리 알려줘서 불필요한 디스크 읽기를 줄여준다.

블룸 필터는 큰 체크 박스와 같다. 특별한 해시 함수 구조로 찾고자 하는 데이터를 넣으면 이 데이터는 몇번, 몇번 부분이 체크돼야한다 라는 값이 나온다. 체크가 안 돼있다면 DB에 없는 것이다. O(1) 로 판단 가능
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

볼륨 필터를 사용했을 때 O(1)으로 판단할 수 있다는 부분에서 어떻게 가능한것인가요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants