003. DBMS and Explain Plan - llighter/database GitHub Wiki
Optimizer Components Oracle Help Center
Stages of SQL Processing Oracle Help Center
์ฌ์ฉ์ ํน์ ๊ฐ๋ฐ์๊ฐ DB์์ ์ฌ์ฉํ๋ ๊ฒ์ SQL๋ ๋ฒจ ๊น์ง๋ค. ์ดํ ๋ชจ๋ ๊ฒ์ DBMS๊ฐ ์ฒ๋ฆฌํ๋ค.
1. ๊ถํ ์ด์์ ์ฃ์
- C, Java, Ruby : ์ ์ฐจ๊ฐ ๊ธฐ์ด๊ฐ ๋๋ ์ธ์ด -> ์ฌ์ฉ์๊ฐ WHAT, HOW๋ฅผ ์ ์
- RDB -> ์ฌ์ฉ์๋ WHAT, ์์คํ ์ด HOW
- ์์ ๋ฐฉ์์ด ์ฑ๋ฅ์์ ์ ๋ฆฌํจ์ด ์์ง๋ง ํญ์ ๊ทธ๋ฐ๊ฒ์ ์๋๊ธฐ ๋๋ฌธ์ ๋ด๋ถ๋ฅผ ๋ค์ฌ๋ค๋ด์ผ ํ๋ค.
2. ๋ฐ์ดํฐ์ ์ ๊ทผํ๋ ๋ฐฉ๋ฒ์ ์ด๋ป๊ฒ ๊ฒฐ์ ํ ๊น?
์ฟผ๋ฆฌ ํ๊ฐ ์์ง(Query Execution Engine) : ๋ฐ์ดํฐ ์ ๊ทผ ์ ์ฐจ๋ฅผ ๊ฒฐ์
- ํ์(parser)
- ๊ตฌ๋ฌธ ๋ถ์
- SQL ๊ตฌ๋ฌธ์ ๊ฒ์ฌํ๊ณ ์ ํ์ ์ธ ํ์์ผ๋ก ๋ณํํด์ค๋ค.
- ์ถ๊ฐ ์ ๋ณด๋ Oracle Help Center์ Stages of SQL Processing ์ฐธ๊ณ
- ์ตํฐ๋ง์ด์ (optimizer)
- ์ตํฐ๋ง์ด์ ๊ฐ DBMS ๋๋์ ํต์ฌ
- ์ถ๊ฐ ์ ๋ณด๋ Oracle Help Center์ Optimizer Components ์ฐธ๊ณ
-
The optimizer receives the parsed query and generates a set of potential plans for the SQL statement based on available access paths and hints.
-
The optimizer estimates the cost of each plan based on statistics in the data dictionary. The cost is an estimated value proportional to the expected resource use needed to execute the statement with a particular plan.
-
The optimizer compares the costs of plans and chooses the lowest-cost plan, known as the query plan, to pass to the row source generator.
3. ์ตํฐ๋ง์ด์ ์ ํต๊ณ ์ ๋ณด
Data Dictionary(์นดํ๋ก๊ทธ)์ ํฌํจ๋์ด ์๋ ํต๊ณ์ ๋ณด๋ ๋ค์๊ณผ ๊ฐ๋ค.
-
Table statistics
- These include the number of rows, number of blocks, and average row length.
-
Column statistics
- These include the number of distinct values and nulls in a column and the distribution of data.
-
Index statistics
- These include the number of leaf blocks and index levels.
-
System statistics
- These include CPU and I/O performance and utilization.
-
์ตํฐ๋ง์ด์ ๊ฐ ์คํ๊ณํ์ ์ธ์ธ๋ ์นดํ๋ก๊ทธ์ ์ ๋ณด๊ฐ ์ ํํ์ง ์๋ค๋ฉด ์ต์ ์ ์คํ๊ณํ์ด ๋์ฌ ์ ์๋ค.
-
'Garbagy In, Garbagy Out'