๐Ÿค” DB ์ธ๋ฑ์‹ฑ์— ๋Œ€ํ•ด

yeeun leeยท2020๋…„ 7์›” 16์ผ
1

์ฐธ๊ณ : how does indexing work

์ธ๋ฑ์‹ฑ

๊ฒ€์ƒ‰ํ•  ๋•Œ ์ฟผ๋ฆฌ์˜ ํšจ์œจ์„ฑ์„ ์ตœ๋Œ€ํ™”ํ•˜๊ธฐ ์œ„ํ•ด ์ •๋ ฌ๋˜์ง€ ์•Š์€ ํ…Œ์ด๋ธ”์„ ์ •๋ ฌ์‹œ์ผœ์ฃผ๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ๋Œ€๋ถ€๋ถ„์˜ DBMS(Mysql, oracle๊ณผ ๊ฐ™์€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ ์‹œ์Šคํ…œ)๋Š” primary key๋ฅผ ์ž๋™์œผ๋กœ ์ธ๋ฑ์‹ฑํ•œ๋‹ค.

Indexing is the way to get an unordered table into an order that will maximize the queryโ€™s efficiency while searching.

b-tree๊ตฌ์กฐ

์ „์‚ฐํ•™์—์„œ B-ํŠธ๋ฆฌ๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ํŒŒ์ผ ์‹œ์Šคํ…œ์—์„œ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ํŠธ๋ฆฌ ์ž๋ฃŒ๊ตฌ์กฐ์˜ ์ผ์ข…์œผ๋กœ, ์ด์ง„ ํŠธ๋ฆฌ๋ฅผ ํ™•์žฅํ•ด ํ•˜๋‚˜์˜ ๋…ธ๋“œ๊ฐ€ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋Š” ์ž์‹ ๋…ธ๋“œ์˜ ์ตœ๋Œ€ ์ˆซ์ž๊ฐ€ 2๋ณด๋‹ค ํฐ ํŠธ๋ฆฌ ๊ตฌ์กฐ์ด๋‹ค.

์–ธ์ œ ์ข‹์ง€?

where, join, order by๊ฐ€ ์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ํ…Œ์ด๋ธ”์— index๋ฅผ ๊ฑธ์–ด์ค˜์•ผ search ์†๋„ ์ƒ์Šนํ•œ๋‹ค. CRUD ์ค‘ R์„ ์ œ์™ธํ•˜๊ณ  delete, insert, update์˜ over head๊ฐ€ ํฌ๊ธฐ ๋•Œ๋ฌธ์— index ๊ฑฐ๋Š” ๊ฒƒ์ด ์ข‹์ง€ ์•Š๋‹ค.

profile
์ด์‚ฌ๊ฐ„ ๋ธ”๋กœ๊ทธ: yenilee.github.io

0๊ฐœ์˜ ๋Œ“๊ธ€