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

[2023-08-11] Intro to Database Systems 9๊ฐ• - Concurrent Indexes #9

Open
jonyejin opened this issue Aug 7, 2023 · 3 comments
Open
Assignees
Labels
Database ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๐Ÿ“ ์Šคํ„ฐ๋”” ์ผ์ง€ ์Šคํ„ฐ๋”” ์ผ์ง€

Comments

@jonyejin
Copy link

jonyejin commented Aug 7, 2023

๐Ÿ“Œ ๊ฐœ์š”

  • ์‹œ๊ฐ„: 2023-08-11(๊ธˆ์š”์ผ) 22:00
  • ์ž๋ฃŒ: 9๊ฐ• Concurrent Indexes
  • ์ฐธ์—ฌ์ž: ํŽญ๊ท„, ๊ทธ๋ฃจํŠธ, ๋ ‰์‚ฌ, ๋‚˜๊ฐ•

โœ๏ธ ์ค€๋น„

์•„๋ž˜ ์–‘์‹์„ ๋ณต์‚ฌํ•ด ์Šคํ„ฐ๋”” ์ค€๋น„๋ฅผ ์™„๋ฃŒํ•ด์ฃผ์„ธ์š”!

## ๐Ÿ’ฌ ์ƒ๊ฐ

<!--๊ฐ•์˜๋ฅผ ๋“ฃ๊ณ  ์ƒ๊ฐํ•œ ๋‚ด์šฉ์„ 3์ค„ ๋‚ด๋กœ ๊ฐ„๋‹จํžˆ ์ •๋ฆฌํ•ด์ฃผ์„ธ์š”!-->

- ...

## โ“ ์งˆ๋ฌธ

<!--๊ณต๋ถ€ํ•˜๋ฉด์„œ ๊ถ๊ธˆํ•œ ์ ์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”!-->

- ...

## ๐Ÿ“š ์ฐธ๊ณ  ์ž๋ฃŒ

<!--๊ณต๋ถ€ํ•˜๋ฉด์„œ ๊ฐ™์ด ๊ณต๋ถ€ํ•œ ์ž๋ฃŒ๋ฅผ ์ฒจ๋ถ€ ๋ฐ ๊ณต์œ ํ•ด์ฃผ์„ธ์š”!-->

- [...](...)
@jonyejin jonyejin changed the title [2023-08-11] ๊ฐ•์˜ 8๊ฐ• - Index Concurrency Control [2023-08-11] Intro to Database Systems 8๊ฐ• - Index Concurrency Control Aug 7, 2023
@CoodingPenguin CoodingPenguin changed the title [2023-08-11] Intro to Database Systems 8๊ฐ• - Index Concurrency Control [2023-08-11] Intro to Database Systems 9๊ฐ• - Index Concurrency Control Aug 7, 2023
@CoodingPenguin CoodingPenguin added ๐Ÿ“ ์Šคํ„ฐ๋”” ์ผ์ง€ ์Šคํ„ฐ๋”” ์ผ์ง€ Database ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค labels Aug 7, 2023
@CoodingPenguin CoodingPenguin changed the title [2023-08-11] Intro to Database Systems 9๊ฐ• - Index Concurrency Control [2023-08-11] Intro to Database Systems 9๊ฐ• - Concurrent Indexes Aug 8, 2023
@CoodingPenguin
Copy link
Member

CoodingPenguin commented Aug 8, 2023

๐Ÿ’ฌ ์ƒ๊ฐ

  • ์ด ๊ต์ˆ˜๋‹˜ ์ •๋ง ๊ดœ์ฐฎ์€๊ฒŒ, ์ €๋ฒˆ ๊ฐ•์˜์—์„œ ๋‹ค ๋‹ต๋ณ€ ๋ชปํ•œ ๊ฑฐ ๋” ๋ณด์ถฉํ•ด์„œ ์„ค๋ช…ํ•ด์ฃผ์‹ ๋‹ค.
  • ๊ฐ•์˜๋ฅผ ๋‹ค ๋ณด์ง„ ๋ชปํ–ˆ๊ณ , Lecture Note๋ฅผ ์ฝ์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค ๋“ฃ๊ณ  ๋ณด์ถฉํ•ด์„œ ์˜ค๊ฒ ์Šต๋‹ˆ๋‹ค..

๐Ÿ“š ์ฐธ๊ณ  ์ž๋ฃŒ

@jonyejin
Copy link
Author

jonyejin commented Aug 9, 2023

โœ”๏ธ ๋‚ด์šฉ ์ •๋ฆฌ

๋ฉ€ํ‹ฐ์“ฐ๋ ˆ๋”ฉ ๋Œ€์‘์„ ํ•ด๋ณด์ž!

  • Lock vs Latch

Latch mode

  • read mode
  • write mode

Latch ๊ตฌํ˜„ ๋ฐฉ๋ฒ•

  • Blocking OS Mutex
  • Test-and-Set Spin Latch
  • Reader-Writer Latches

Hash Table์—์„œ Latch ๊ตฌํ˜„ ๋ฐฉ๋ฒ•

  • Page Latches
  • Slot Latches

Compare-and-swap

B+Tree

  • B+ Tree Latching: Latch Crabbing / Coupling => ๋…ธ๋“œ ์‚ญ์ œ ๋ฐ ์ถ”๊ฐ€ ํ• ๋•Œ๋งŒ latch๋ฅผ ๊ฑธ์ž.
  • leaf node scans:

๊ฒฐ๋ก 

  • thread-safeํ•œ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ๋งŒ๋“œ๋Š”๊ฑด ์ •๋ง ์–ด๋ ต๋‹ค
  • B+Tree๋งŒ ๋ดค์ง€๋งŒ ๋‹ค๋ฅธ ์ž๋ฃŒ๊ตฌ์กฐ์—๋„ ๋ฐฉ๋ฒ•๋ก ์€ ๋น„์Šทํ•˜๊ฒŒ ์ ์šฉ๋œ๋‹ค.

@Nagunt
Copy link
Contributor

Nagunt commented Aug 11, 2023

๐Ÿ’ฌ ์ƒ๊ฐ

  • ์ „ ppt์—์„œ ํ•˜์ง€ ์•Š์•˜๋˜ ๋ถ€๋ถ„์„ ๊ฐ•์˜ ์‹œ์ž‘ ๋ถ€๋ถ„์— ๋งˆ์ € ํ•˜๊ณ  ๋„˜์–ด๊ฐ”๋‹ค.
  • B+ Tree์˜ node size๋Š” ์ €์žฅ ๊ธฐ๊ธฐ๊ฐ€ ๋Š๋ฆด์ˆ˜๋ก ๋” ์ปค์ง„๋‹ค. (์‹œ๊ฐ„ ๋ณต์žก๋„๋ฅผ ์ตœ๋Œ€ํ•œ ์ค„์ด๋Š” ๋ถ€๋ถ„์ธ๋“ฏ?)
    • ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์ตœ์ ํ™” ๊ธฐ๋ฒ•๋“ค์„ ์†Œ๊ฐœํ•˜์˜€๋‹ค.
    • ์•”ํŠผ DBMS์—์„œ๋Š” B+Tree๊ฐ€ ์ตœ๊ณ ๋‹ค.
  • ๋“œ๋””์–ด ๋ฉ€ํ‹ฐ์“ฐ๋ ˆ๋“œ ํ™˜๊ฒฝ์—์„œ์˜ ๋ฐ์ดํ„ฐ ์ ‘๊ทผ ๊ด€๋ฆฌ ๋ฐฉ์‹์— ๋Œ€ํ•ด์„œ ๋ฐฐ์šด๋‹ค. Concurrency : ๋™์‹œ์„ฑ, ๋ณ‘๋ ฌํ™”.
  • Latch๋ฅผ ํ™œ์šฉํ•ด์„œ ๋ฉ€ํ‹ฐ์“ฐ๋ ˆ๋“œ์˜ I/O๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค. Read๋Š” ์—ฌ๋Ÿฌ ์“ฐ๋ ˆ๋“œ์—์„œ ๋™์‹œ์— ์ฝ์„ ์ˆ˜ ์žˆ์ง€๋งŒ, Write๋Š” ์˜ค์ง ํ•œ ์“ฐ๋ ˆ๋“œ๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค.
    • Hash Table์—์„œ์˜ Latching : Page๋ณ„๋กœ, Slot ๋ณ„๋กœ.
    • B+Tree์—์„œ์˜ Latching : Latch Crabbing/Coupling. Node๋ณ„๋กœ Latch๋ฅผ ๋ถ€์—ฌํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์ธ๋‹ค.
    • ๊ธฐ์กด ๋ฐฉ์‹์—์„œ๋Š” Write๋ฅผ ํ•  ๋•Œ ์–ธ์ œ๋‚˜ ์ตœ์ƒ์œ„ Node์— latch๊ฐ€ ๊ฑธ๋ฆฌ๋ฏ€๋กœ ์ด๋ฅผ ๊ฐœ์„ ํ•œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ๋“ฑ์žฅ.
      • ์˜ค์ง Leaf์—๋งŒ Write latch๋ฅผ ๊ฑธ๋ฉฐ, Leaf๋งŒ unsafeํ•˜๋‹ค๊ณ  ๊ฐ€์ •. ๊ทธ๋Ÿฌ๋‚˜ ์œ„ Node๊นŒ์ง€ ์ •๋ ฌํ•ด์•ผ ํ•  ๊ฒฝ์šฐ ๋‹ค์‹œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•œ๋‹ค๋Š” ๋ฌธ์ œ์ ์ด ์žˆ์Œ.
  • Latch๋Š” deadlock์— ๋Œ€ํ•ด์„œ deadlock ๊ฐ์ง€๋‚˜ ํšŒํ”ผ๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค. ์ด๋Š” ์˜ค์ง coding์„ ํ†ตํ•ด์„œ๋งŒ ํ•ด๊ฒฐํ•ด์•ผ ํ•œ๋‹ค.
  • thead-safeํ•œ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์€ ๋งค์šฐ๋งค์šฐ๋งค์šฐ!!!! ์–ด๋ ค์šด ์ผ์ด๋‹ค.

โ“ ์งˆ๋ฌธ

  • 9์žฅ PPT 4/88์—์„œ Physical Correctness์— ๋Œ€ํ•ด์„œ ์„ค๋ช…ํ•œ ๋ถ€๋ถ„์ด ๋ฌธ์žฅ์ด ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ. Is the internal representation of the object sound? ๋ผ๋Š”๋ฐ internal representation์€ ๋‚ด์  ํ‘œ์ƒ์œผ๋กœ ํ•ด์„ํ–ˆ๋Š”๋ฐ object sound ๋ผ๋Š”๊ฒŒ ๋Œ€์ฒด ๋ญ” ๋œป์ธ์ง€ ๋ชจ๋ฅด๊ฒ ์Œ.
    • sound๋Š” ์•ˆ์ •ํ•œ ์ด๋ผ๋Š” ๋œป์ด ์žˆ๋‹ค. ๊ฐ์ฒด์˜ ๋‚ด์  ํ‘œ์ƒ์ด ์•ˆ์ •ํ•œ๊ฐ€?

๐Ÿ“š ์ฐธ๊ณ  ์ž๋ฃŒ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Database ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๐Ÿ“ ์Šคํ„ฐ๋”” ์ผ์ง€ ์Šคํ„ฐ๋”” ์ผ์ง€
Projects
None yet
Development

No branches or pull requests

4 participants