Skip to content

Latest commit

ย 

History

History
428 lines (359 loc) ยท 36.4 KB

Section4-1.md

File metadata and controls

428 lines (359 loc) ยท 36.4 KB

4.1 MySQL ์—”์ง„ ์•„ํ‚คํ…์ฒ˜

4.1.1 MySQL์˜ ์ „์ฒด ๊ตฌ์กฐ

  • MySQL์€ ๋Œ€๋ถ€๋ถ„์˜ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋กœ๋ถ€ํ„ฐ ์ ‘๊ทผ ๋ฐฉ๋ฒ•์„ ๋ชจ๋‘ ์ง€์›ํ•œ๋‹ค.
    • C API, JDBC, ODBC, .NET ํ‘œ์ค€ ๋“œ๋ผ์ด๋ฒ„ ์ œ๊ณตํ•˜์—ฌ C/C++, PHP, ์ž๋ฐ”, ํŽ„, ํŒŒ์ด์ฌ, ๋ฃจ๋น„ .NET ๋ฐ ์ฝ”๋ณผ๊นŒ์ง€ ๋ชจ๋“  ์–ธ์–ด๋กœ MySQL ์„œ๋ฒ„์—์„œ ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
  • MySQL์„œ๋ฒ„ = MySQL ์—”์ง„ + ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„

4.1.1.1 MySQL ์—”์ง„

  • MySQL ์—”์ง„ = ์ปค๋„ฅ์…˜ ํ•ธ๋“ค๋Ÿฌ(ํด๋ผ์ด์–ธํŠธ ์ ‘์†) + SQL ํŒŒ์„œ ๋ฐ ์ „์ฒ˜๋ฆฌ๊ธฐ(์ฟผ๋ฆฌ ์š”์ฒญ ์ฒ˜๋ฆฌ) + ์˜ตํ‹ฐ๋งˆ์ด์ €(์ฟผ๋ฆฌ ์ตœ์ ํ™”)
  • MySQL์€ ํ‘œ์ค€ SQL๋ฌธ๋ฒ•์„ ์ง€์›ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ํƒ€ DBMS์™€ ํ˜ธํ™˜๋˜์–ด ์‹คํ–‰๋  ์ˆ˜ ์žˆ๋‹ค.

4.1.1.2 ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„

  • MySQL ์—”์ง„์€ ์š”์ฒญ๋œ SQL ๋ถ„์„ ๋ฐ ์ตœ์ ํ™”๋“ฑ DBMS์˜ ๋‘๋‡Œ๋ฅผ ๋‹ด๋‹น
  • ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์€ ์‹ค์ œ ๋ฐ์ดํ„ฐ๋ฅผ ๋””์Šคํฌ ์Šคํ† ๋ฆฌ์ง€์— ์ €์žฅํ•˜๊ฑฐ๋‚˜ ์ฝ์–ด์˜ค๋Š” ๋ถ€๋ถ„์„ ๋‹ด๋‹น
  • MySQL ์„œ๋ฒ„์—์„œ ์—”์ง„์€ ํ•˜๋‚˜์ง€๋งŒ, ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์€ ์—ฌ๋Ÿฌ๊ฐœ๋ฅผ ๋™์‹œ์— ์‚ฌ์šฉ ๊ฐ€๋Šฅ
CREATE TABLE test_table (fd1 INT, fd2 INT) ENGINE=INNODB;

์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์„ ์ง€์ •ํ•˜๋ฉด, ํ•ด๋‹น ํ…Œ์ด๋ธ”์˜ ๋ชจ๋“  ์ž‘์—…์€ ์ •์˜๋œ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์ด ์ฒ˜๋ฆฌํ•œ๋‹ค.

  • ๊ฐ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์€ ์„ฑ๋Šฅ ํ–ฅ์ƒ์„ ์œ„ํ•ด ํ‚ค ์บ์‹œ(MyISAM)๋‚˜ InnoDB ๋ฒ„ํผ ํ’€(InnoDB)๊ฐ™์€ ๊ธฐ๋Šฅ์„ ๋‚ด์žฅํ•˜๊ณ  ์žˆ๋‹ค.

4.1.1.3 ํ•ธ๋“ค๋Ÿฌ API

  • MySQL ์—”์ง„์˜ ์ฟผ๋ฆฌ ์‹คํ–‰๊ธฐ์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์“ฐ๊ฑฐ๋‚˜ ์ฝ์–ด์•ผ ํ•  ๋•Œ ๊ฐ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์— ์š”์ฒญํ•œ๋‹ค.

  • ์ด๋ฅผ Handler ์š”์ฒญ์ด๋ผ ํ•˜๋ฉฐ, ์‚ฌ์šฉ๋˜๋Š” API๋ฅผ Handler API๋ผ๊ณ  ํ•œ๋‹ค.

  • ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„ ๋˜ํ•œ ์ด Handler API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ MySQL ์—”์ง„๊ณผ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š”๋‹ค.

  • ์•„๋ž˜ ์ฟผ๋ฆฌ๋กœ ์–ผ๋งˆ๋‚˜ ๋งŽ์€ ๋ฐ์ดํ„ฐ ์ž‘์—…์ด ์žˆ์—ˆ๋Š”์ง€ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค

mysql> SHOW GLOBAL STATUS LIKE 'Handler%';
+----------------------------+-----------+
| Variable_name              | Value     |
+----------------------------+-----------+
| Handler_commit             | 32304704  |
| Handler_delete             | 867       |
| Handler_discover           | 0         |
| Handler_external_lock      | 60029128  |
| Handler_mrr_init           | 0         |
| Handler_prepare            | 0         |
| Handler_read_first         | 924338    |
| Handler_read_key           | 361550629 |
| Handler_read_last          | 0         |
| Handler_read_next          | 711585244 |
| Handler_read_prev          | 0         |
| Handler_read_rnd           | 953       |
| Handler_read_rnd_next      | 3304411   |
| Handler_rollback           | 104       |
| Handler_savepoint          | 0         |
| Handler_savepoint_rollback | 0         |
| Handler_update             | 746       |
| Handler_write              | 1107501   |
+----------------------------+-----------+
18 rows in set (0.11 sec)

4.1.2 MySQL ์Šค๋ ˆ๋”ฉ ๊ตฌ์กฐ

  • MySQL ์„œ๋ฒ„๋Š” ํ”„๋กœ์„ธ์Šค ๊ธฐ๋ฐ˜์ด ์•„๋‹ˆ๋ผ ์Šค๋ ˆ๋“œ ๊ธฐ๋ฐ˜์œผ๋กœ ์ž‘๋™ํ•˜๋ฉฐ, ํฌ๊ทธ๋ผ์šด๋“œ(Foreground)์Šค๋ ˆ๋“œ์™€ ๋ฐฑ๊ทธ๋ผ์šด๋“œ(Background)์Šค๋ ˆ๋“œ๋กœ ํƒ€์ž…์„ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ๋‹ค.
mysql> SELECT thread_id, name, type, processlist_user, processlist_host
       FROM performance_schema.threads ORDER BY type, thread_id;
+-----------+----------------------------------------+------------+------------------+------------------+
| thread_id | name                                   | type       | processlist_user | processlist_host |
+-----------+----------------------------------------+------------+------------------+------------------+
|         1 | thread/sql/main                        | BACKGROUND | NULL             | NULL             |
|         2 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|         3 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|         4 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|         5 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|         6 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|         7 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|         8 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|         9 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|        10 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|        11 | thread/innodb/io_handler_thread        | BACKGROUND | NULL             | NULL             |
|        12 | thread/innodb/srv_purge_thread         | BACKGROUND | NULL             | NULL             |
|        13 | thread/innodb/srv_monitor_thread       | BACKGROUND | NULL             | NULL             |
|        14 | thread/innodb/srv_master_thread        | BACKGROUND | NULL             | NULL             |
|        15 | thread/innodb/srv_error_monitor_thread | BACKGROUND | NULL             | NULL             |
|        16 | thread/innodb/srv_lock_timeout_thread  | BACKGROUND | NULL             | NULL             |
|        18 | thread/sql/signal_handler              | BACKGROUND | NULL             | NULL             |
|        19 | thread/innodb/page_cleaner_thread      | BACKGROUND | NULL             | NULL             |
|    126505 | thread/sql/one_connection              | FOREGROUND | root             | localhost        |
+-----------+----------------------------------------+------------+------------------+------------------+
19 rows in set (0.12 sec)
  • MySQL ์„œ๋ฒ„์—์„œ ์‹คํ–‰์ค‘์ธ ์Šค๋ ˆ๋“œ๋Š” performance_schema ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ threads ํ…Œ์ด๋ธ”์„ ํ†ตํ•ด ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ๋ฐฑ๊ทธ๋ผ์šด๋“œ์™€ ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ๊ฐ€ type์œผ๋กœ ํ‘œ์‹œ๋˜์–ด ์žˆ์œผ๋ฉฐ, ๊ทธ ์ค‘ ๋งˆ์ง€๋ง‰ thread/sql/one_connection ์Šค๋ ˆ๋“œ๋งŒ์ด ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ์ด๋‹ค.
  • ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ ๊ฐœ์ˆ˜๋Š” MySQL ์„œ๋ฒ„์˜ ์„ค์ • ๋‚ด์šฉ์— ๋”ฐ๋ผ ๊ฐ€๋ณ€์ ์ผ ์ˆ˜ ์žˆ๋‹ค.
  • ๋™์ผํ•œ ์ด๋ฆ„์˜ ์Šค๋ ˆ๋“œ๊ฐ€ 2๊ฐœ ์ด์ƒ์”ฉ ๋ณด์ด๋Š” ๊ฒƒ๋„ MySQL ์„œ๋ฒ„ ์„ค์ •์— ์˜ํ•ด ์—ฌ๋Ÿฌ ์Šค๋ ˆ๋“œ๊ฐ€ ๋™์ผ ์ž‘์—…์„ ๋ณ‘๋ ฌ๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒฝ์šฐ์ด๋‹ค.

์ฐธ๊ณ : ์—ฌ๊ธฐ์„œ ์†Œ๊ฐœํ•˜๋Š” ์Šค๋ ˆ๋“œ ๋ชจ๋ธ์€ ์ปค๋ฎค๋‹ˆํ‹ฐ ์—๋””์…˜์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ „ํ†ต์ ์ธ ์Šค๋ ˆ๋“œ ๋ชจ๋ธ์ด๋‹ค. ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์—๋””์…˜๊ณผ Percona MySQL์„œ๋ฒ„์—์„œ๋Š” ์Šค๋ ˆ๋“œ ํ’€(Thread Pool)๋ชจ๋ธ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
๊ฐ€์žฅ ํฐ ์ฐจ์ด์ ์€ ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ์™€ ์ปค๋„ฅ์…˜์˜ ๊ด€๊ณ„์ด๋‹ค. ์ „ํ†ต์ ์ธ ์Šค๋ ˆ๋“œ ๋ชจ๋ธ์€ ์ปค๋„ฅ์…˜๋ณ„ ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ๊ฐ€ ํ•˜๋‚˜์”ฉ ์ƒ์„ฑ๋˜์ง€๋งŒ ์Šค๋ ˆ๋“œํ’€์—์„œ๋Š” ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๊ฐ€ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ปค๋„ฅ์…˜ ์š”์ฒญ์„ ์ „๋‹ดํ•œ๋‹ค.

4.1.2.1 ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ(ํด๋ผ์ด์–ธํŠธ ์Šค๋ ˆ๋“œ)

  • ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ๋Š” ์ตœ์†Œ MySQL ์„œ๋ฒ„์— ์ ‘์†๋œ ํด๋ผ์ด์–ธํŠธ์˜ ์ˆ˜๋งŒํผ ์กด์žฌํ•˜๋ฉฐ, ๊ฐ ํด๋ผ์ด์–ธํŠธ ์‚ฌ์šฉ์ž๊ฐ€ ์š”์ฒญํ•˜๋Š” ์ฟผ๋ฆฌ ๋ฌธ์žฅ์„ ์ฒ˜๋ฆฌํ•œ๋‹ค.
  • ์ปค๋„ฅ์…˜์„ ์ข…๋ฃŒํ•˜๋ฉด ์ปค๋„ฅ์…˜์„ ๋‹ด๋‹นํ•˜๋˜ ์Šค๋ ˆ๋“œ๋Š” ๋‹ค์‹œ ์Šค๋ ˆ๋“œ ์บ์‹œ(Thread cache)๋กœ ๋˜๋Œ์•„๊ฐ„๋‹ค.
  • ์ด๋ฏธ ์Šค๋ ˆ๋“œ ์บ์‹œ์— ์ผ์ • ๊ฐœ์ˆ˜ ์ด์ƒ์˜ ๋Œ€๊ธฐ์ค‘์ธ ์Šค๋ ˆ๋“œ๊ฐ€ ์žˆ๋‹ค๋ฉด, ์Šค๋ ˆ๋“œ ์บ์‹œ์— ๋„ฃ์ง€ ์•Š๊ณ  ์Šค๋ ˆ๋“œ๋ฅผ ์ข…๋ฃŒ์‹œ์ผœ ์ผ์ • ๊ฐœ์ˆ˜์˜ ์Šค๋ ˆ๋“œ๋งŒ ์Šค๋ ˆ๋“œ ์บ์‹œ์— ์กด์žฌํ•˜๊ฒŒ ํ•œ๋‹ค.
  • ์ด๋•Œ ์Šค๋ ˆ๋“œ ์บ์‹œ์— ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€ ์Šค๋ ˆ๋“œ ๊ฐœ์ˆ˜๋Š” thread_cache_size ์‹œ์Šคํ…œ ๋ณ€์ˆ˜๋กœ ์„ค์ •ํ•œ๋‹ค.
  • ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ๋Š” ๋ฐ์ดํ„ฐ๋ฅผ MySQL์˜ ๋ฐ์ดํ„ฐ ๋ฒ„ํผ๋‚˜ ์บ์‹œ๋กœ๋ถ€ํ„ฐ ๊ฐ€์ ธ์˜ค๋ฉฐ, ๋ฒ„ํผ๋‚˜ ์บ์‹œ์— ์—†๋Š” ๊ฒฝ์šฐ ์ง์ ‘ ๋””์Šคํฌ ๋˜๋Š” ์ธ๋ฑ์ŠคํŒŒ์ผ๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์™€์„œ ์ฒ˜๋ฆฌํ•œ๋‹ค.
  • MyISAM ํ…Œ์ด๋ธ”์€ ๋””์Šคํฌ ์“ฐ๊ธฐ ์ž‘์—…๊นŒ์ง€ ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ๊ฐ€ ์ฒ˜๋ฆฌํ•˜์ง€๋งŒ,
  • InnoDB ํ…Œ์ด๋ธ”์€ ๋ฐ์ดํ„ฐ ๋ฒ„ํผ๋‚˜ ์บ์‹œ๊นŒ์ง€๋งŒ ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ๊ฐ€ ์ฒ˜๋ฆฌํ•˜๊ณ  ๋‚˜๋จธ์ง€ ๋ฒ„ํผ๋กœ๋ถ€ํ„ฐ ๋””์Šคํฌ๊นŒ์ง€ ๊ธฐ๋กํ•˜๋Š” ์ž‘์—…์€ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ๊ฐ€ ์ฒ˜๋ฆฌํ•œ๋‹ค.

์‚ฌ์šฉ์ž ์Šค๋ ˆ๋“œ == ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ
MySQL ์„œ๋ฒ„์— ์ ‘์†ํ•˜๊ฒŒ ๋˜๋ฉด ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•ด์ค„ ์Šค๋ ˆ๋“œ๋ฅผ ์ƒ์„ฑํ•ด ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ํ• ๋‹นํ•œ๋‹ค. ์ด ์Šค๋ ˆ๋“œ๋Š” ์•ž๋‹จ์—์„œ ํด๋ผ์ด์–ธํŠธ์™€ ํ†ต์‹ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํฌ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ๋ผ๊ณ  ํ•˜๋ฉฐ, ์‚ฌ์šฉ์ž๊ฐ€ ์š”์ฒญํ•œ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉ์ž ์Šค๋ ˆ๋“œ๋ผ๊ณ ๋„ ํ•œ๋‹ค.

4.1.2.2 ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์Šค๋ ˆ๋“œ

MyISAM์˜ ๊ฒฝ์šฐ ํ•ด๋‹น ์‚ฌํ•ญ์ด ์—†์ง€๋งŒ, InnoDB๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ์ž‘์—…์ด ๋ฐฑ๊ทธ๋ผ์šด๋“œ๋กœ ์ฒ˜๋ฆฌ๋œ๋‹ค.

  • ์ธ์„œํŠธ ๋ฒ„ํผ(Insert Buffer)๋ฅผ ๋ณ‘ํ•ฉํ•˜๋Š” ์Šค๋ ˆ๋“œ
  • ๋กœ๊ทธ๋ฅผ ๋””์Šคํฌ๋กœ ๊ธฐ๋กํ•˜๋Š” ์Šค๋ ˆ๋“œ
  • InnoDB ๋ฒ„ํผ ํ’€์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋””์Šคํฌ์— ๊ธฐ๋กํ•˜๋Š” ์Šค๋ ˆ๋“œ
  • ๋ฐ์ดํ„ฐ๋ฅผ ๋ฒ„ํผ๋กœ ์ฝ์–ด ์˜ค๋Š” ์Šค๋ ˆ๋“œ
  • ์ž ๊ธˆ์ด๋‚˜ ๋ฐ๋“œ๋ฝ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๋Š” ์Šค๋ ˆ๋“œ

๊ฐ€์žฅ ์ค‘์š”ํ•œ๊ฒƒ์€ ์“ฐ๊ธฐ ์“ฐ๋ ˆ๋“œ(Write thread)์ด๋‹ค.

  • ์“ฐ๊ธฐ ์“ฐ๋ ˆ๋“œ๋Š” ๋กœ๊ทธ ์Šค๋ ˆ๋“œ(Log thread)์™€ ๋ฒ„ํผ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋””์Šคํฌ๋กœ ๋‚ด๋ ค์“ฐ๋Š” ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•จ.
  • MySQL5.5 ๋ฒ„์ „๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ ์“ฐ๊ธฐ ์Šค๋ ˆ๋“œ์™€ ๋ฐ์ดํ„ฐ ์ฝ๊ธฐ ์Šค๋ ˆ๋“œ์˜ ๊ฐœ์ˆ˜๋ฅผ 2๊ฐœ ์ด์ƒ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋์œผ๋ฉฐ,
  • innodb_write_io_threads, innodb_read_io_threads ์‹œ์Šคํ…œ ๋ณ€์ˆ˜๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • InnoDB์—์„œ๋„ ์ฝ๋Š”๊ฑด ์ฃผ๋กœ ํด๋ผ์ด์–ธํŠธ ์Šค๋ ˆ๋“œ์—์„œ ์ฒ˜๋ฆฌ๋˜๊ธฐ๋•Œ๋ฌธ์— ์ฝ๊ธฐ ์“ฐ๋ ˆ๋“œ๋ฅผ ๋งŽ์ด ์„ค์ •ํ•  ํ•„์š”๊ฐ€ ์—†์ง€๋งŒ
  • ์“ฐ๊ธฐ ์Šค๋ ˆ๋“œ๋Š” ์•„์ฃผ ๋งŽ์€ ์ž‘์—…์„ ๋ฐฑ๊ทธ๋ผ์šด๋“œ๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๋””์Šคํฌ๋Š” 2~4 ์Šคํ† ๋ฆฌ์ง€(DAS, SAN)๋Š” ๋””์Šคํฌ๋ฅผ ์ตœ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์„ ๋งŒํผ ์ถฉ๋ถ„ํžˆ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋„์ค‘ ์“ฐ๊ธฐ ์ž‘์—…์€ ์ง€์—ฐ(๋ฒ„ํผ๋ง)๋˜์–ด๋„ ์ฒ˜๋ฆฌ๋  ์ˆ˜ ์žˆ์ง€๋งŒ, ๋ฐ์ดํ„ฐ์˜ ์ฝ๊ธฐ ์ž‘์—…์€ ์ ˆ๋Œ€ ์ง€์—ฐ๋  ์ˆ˜ ์—†๋‹ค.

  • ๋Œ€๋ถ€๋ถ„ ์“ฐ๊ธฐ ์ž‘์—…์„ ๋ฒ„ํผ๋งํ•ด์„œ ์ผ๊ด„ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ธฐ๋Šฅ์ด ํƒ‘์žฌ๋˜์–ด ์žˆ๋‹ค = InnoDB
  • ํ•˜์ง€๋งŒ MyISAM์€ ์‚ฌ์šฉ์ž ์“ฐ๋ ˆ๋“œ๊ฐ€ ์“ฐ๊ธฐ ์ž‘์—…๊นŒ์ง€ ํ•จ๊ป˜ ์ฒ˜๋ฆฌํ•˜๋„๋ก ์„ค๊ณ„๋˜์–ด ์žˆ๋‹ค.
  • ์ด๋Ÿฌํ•œ ์ด์œ ๋กœ InnoDB์—์„œ๋Š” INSERT, UPDATE, DELETE ์ฟผ๋ฆฌ๋กœ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋Š” ๊ฒฝ์šฐ ๋ฐ์ดํ„ฐ๊ฐ€ ๋””์Šคํฌ๋กœ ์™„์ „ํžˆ ์ €์žฅ๋  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆฌ์ง€ ์•Š์•„๋„ ๋œ๋‹ค.
  • ํ•˜์ง€๋งŒ MyISAM์—์„œ ์ผ๋ฐ˜์ ์ธ ์ฟผ๋ฆฌ๋Š” ์“ฐ๊ธฐ ๋ฒ„ํผ๋ง์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค.

4.1.3 ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น ๋ฐ ์‚ฌ์šฉ ๊ตฌ์กฐ

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-04-16 แ„‹แ…ฉแ„’แ…ฎ 11 28 22
  • ๊ธ€๋กœ๋ฒŒ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ : ๋ชจ๋“  ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์€ MySQL ์„œ๋ฒ„๊ฐ€ ์‹œ์ž‘๋˜๋ฉด์„œ ์‹œ์Šคํ…œ ๋ณ€์ˆ˜๋กœ ์„ค์ •ํ•ด ๋‘” ๋งŒํผ OS๋กœ๋ถ€ํ„ฐ ํ• ๋‹น๋œ๋‹ค.
  • ๋กœ์ปฌ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ

4.1.3.1 ๊ธ€๋กœ๋ฒŒ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ

์ผ๋ฐ˜์ ์œผ๋กœ ํ•˜๋‚˜์˜ ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„๋งŒ ํ• ๋‹น๋œ๋‹ค. ํ•„์š”์— ์˜ํ•ด 2๊ฐœ ์ด์ƒ์„ ๋ฐ›์„ ์ˆ˜ ๋„ ์žˆ์ง€๋งŒ ํด๋ผ์ด์–ธํŠธ ์Šค๋ ˆ๋“œ ์ˆ˜์™€ ๋ฌด๊ด€ํ•˜๋‹ค. N๊ฐœ๋ผ ํ•˜๋”๋ผ๋„ ๋ชจ๋“  ์Šค๋ ˆ๋“œ์— ์˜ํ•ด ๊ณต์œ ๋œ๋‹ค.

[๋Œ€ํ‘œ์ ์ธ ๊ธ€๋กœ๋ฒŒ ๋ฉ”๋ชจ๋ฆฌ์˜์—ญ]

  • ํ…Œ์ด๋ธ” ์บ์‹œ
  • InnoDB ๋ฒ„ํผํ’€
  • InnoDB ์–ด๋Œ‘ํ‹ฐ๋ธŒ ํ•ด์‹œ ์ธ๋ฑ์Šค
  • InnoDB ๋ฆฌ๋‘ ๋กœ๊ทธ ๋ฒ„ํผ

4.1.3.2 ๋กœ์ปฌ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ

์„ธ์…˜ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์ด๋ผ๊ณ ๋„ ํ‘œํ˜„ํ•˜๋ฉฐ, ํด๋ผ์ด์–ธํŠธ ์Šค๋ ˆ๋“œ๊ฐ€ ์ฟผ๋ฆฌ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์ด๋‹ค. = ํด๋ผ์ด์–ธํŠธ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ

  • ํด๋ผ์ด์–ธํŠธ๊ฐ€ MySQL ์„œ๋ฒ„์— ์ ‘์†ํ•˜๋ฉด ํด๋ผ์ด์–ธํŠธ ์ปค๋„ฅ์…˜์œผ๋กœ๋ถ€ํ„ฐ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์Šค๋ ˆ๋“œ๋ฅผ ํ•˜๋‚˜์”ฉ ํ• ๋‹นํ•˜๊ฒŒ ๋˜๋ฉฐ, ํ•ด๋‹น ์Šค๋ ˆ๋“œ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์ด๋‹ค.
  • ์„œ๋ฒ„์™€์˜ ์ปค๋„ฅ์…˜์„ ์„ธ์…˜์ด๋ผ๊ณ  ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋กœ์ปฌ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์„ ์„ธ์…˜ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์ด๋ผ๊ณ ๋„ ํ‘œํ˜„ํ•œ๋‹ค.

๋กœ์ปฌ ๋ฉ”๋ชจ๋ฆฌ๋Š” ๊ฐ ํด๋ผ์ด์–ธํŠธ ์Šค๋ ˆ๋“œ๋ณ„๋กœ ๋…๋ฆฝ์ ์œผ๋กœ ํ• ๋‹น๋˜๋ฉฐ ์ ˆ๋Œ€ ๊ณต์œ ๋˜์ง€ ์•Š๋Š”๋‹ค.

  • ๊ธ€๋กœ๋ฒŒ ๋ฉ”๋ชจ๋ฆฌ์˜์—ญ์˜ ํฌ๊ธฐ๋Š” ์ฃผ์˜ํ•ด์„œ ์„ค์ •ํ•ด์•ผํ•˜์ง€๋งŒ, ๋กœ์ปฌ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์€ ํฌ๊ฒŒ ์‹ ๊ฒฝ์“ฐ์ง€ ์•Š๊ณ  ์„ค์ •ํ•œ๋‹ค.
  • ๊ฐ€๋Šฅ์„ฑ์€ ํฌ๋ฐ•ํ•˜์ง€๋งŒ ์„œ๋ฒ„๊ฐ€ ๋ฉ”๋ชจ๋ฆฌ ๋ถ€์กฑ์œผ๋กœ ๋ฉˆ์ถฐ ๋ฒ„๋ฆด ์ˆ˜ ๋„ ์žˆ์œผ๋ฏ€๋กœ ์ ์ ˆํ•œ ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์„ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค.

๊ฐ ์ฟผ๋ฆฌ์˜ ์šฉ๋„๋ณ„๋กœ ํ•„์š”ํ•  ๋•Œ๋งŒ ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์ด ํ• ๋‹น๋˜๊ณ  ํ•„์š”ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ํ• ๋‹น๋˜์ง€ ์•Š๋Š”๋‹ค.

  • ์ปค๋„ฅ์…˜์ด ์—ด๋ ค ์žˆ๋Š” ๋™์•ˆ ๊ณ„์† ํ• ๋‹น๋œ ์ƒํƒœ๋กœ ๋‚จ์•„์žˆ๋Š” ๊ณต๊ฐ„๋„ ์žˆ๊ณ  (์ปค๋„ฅ์…˜ ๋ฒ„ํผ๋‚˜ ๊ฒฐ๊ณผ ๋ฒ„ํผ)
  • ์ฟผ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ์ˆœ๊ฐ„์—๋งŒ ํ• ๋‹นํ–ˆ๋‹ค๊ฐ€ ๋‹ค์‹œ ํ•ด์ œํ•˜๋Š” ๊ณต๊ฐ„๋„ ์žˆ๋‹ค. (์†ŒํŠธ ๋ฒ„ํผ๋‚˜ ์กฐ์ธ ๋ฒ„ํผ)

[๋Œ€ํ‘œ์ ์ธ ๋กœ์ปฌ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ]

  • ์ •๋ ฌ ๋ฒ„ํผ(Sort Buffer)
  • ์กฐ์ธ ๋ฒ„ํผ
  • ๋ฐ”์ด๋„ˆ๋ฆฌ ๋กœ๊ทธ ์บ์‹œ
  • ๋„คํŠธ์›Œํฌ ๋ฒ„ํผ

4.1.4 ํ”Œ๋Ÿฌ๊ทธ์ธ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„ ๋ชจ๋ธ

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-04-16 แ„‹แ…ฉแ„’แ…ฎ 11 51 10

MySQL์€ ํ”Œ๋Ÿฌ๊ทธ์ธ ๋ชจ๋ธ์ด๋‹ค.

  • ์ˆ˜๋งŽ์€ ์‚ฌ์šฉ์ž์˜ ์š”๊ตฌ ์กฐ๊ฑด์„ ๋งŒ์กฑ์‹œํ‚ค๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ๋‹ค์ˆ˜ ์žˆ๋‹ค.
  • ์Šค๋กœ๋ฆฌ์ง€ ์—”์ง„๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๊ฒ€์ƒ‰์–ด ํŒŒ์„œ, ์‚ฌ์šฉ์ž ์ธ์ฆ ๋“ฑ ๋ชจ๋‘ ํ”Œ๋Ÿฌ๊ธด์œผ๋กœ ๊ตฌํ˜„๋˜์–ด ์ œ๊ณต๋œ๋‹ค.
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-04-16 แ„‹แ…ฉแ„’แ…ฎ 11 55 29

MySQL์—์„œ ์ฟผ๋ฆฌ๊ฐ€ ์‹คํ–‰๋˜๋Š” ๊ณผ์ •์„ ๋ณด๋ฉด ๋Œ€๋ถ€๋ถ„์˜ ์ž‘์—…์€ MySQL ์—”์ง„์—์„œ ์ฒ˜๋ฆฌ๋˜๊ณ  ๋งˆ์ง€๋ง‰ ๋ฐ์ดํ„ฐ ์ฝ๊ธฐ/์“ฐ๊ธฐ์ž‘์—…๋งŒ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์— ์˜ํ•ด ์ฒ˜๋ฆฌ๋œ๋‹ค.

  • ๋ฐ์ดํ„ฐ ์ฝ๊ธฐ/์“ฐ๊ธฐ์ž‘์—…์€ ๋Œ€๋ถ€๋ถ„ 1๊ฑด์˜ ๋ ˆ์ฝ”๋“œ ๋‹จ์œ„๋กœ ์ฒ˜๋ฆฌ๋œ๋‹ค.
  • MySQL ์„œ๋ฒ„์—์„œ MySQL ์—”์ง„(์‚ฌ๋žŒ)์€ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„(์ž๋™์ฐจ)์„ ์กฐ์ •ํ•˜๊ธฐ ์œ„ํ•ด ํ•ธ๋“ค๋Ÿฌ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
    • Handler: ์–ด๋–ค ๊ธฐ๋Šฅ์„ ํ˜ธ์ถœํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ์šด์ „๋Œ€์™€ ๊ฐ™์€ ์—ญํ• ์„ ํ•˜๋Š” ๊ฐ์ฒด
  • MySQL์„œ๋ฒ„์˜ ์ƒํƒœ ๋ณ€์ˆ˜ ์ค‘ Handler_๋กœ ์‹œ์ž‘ํ•˜๋Š” ๊ฒƒ์ด ๋งŽ๋‹ค.
    • Handler_๋กœ ์‹œ์ž‘ํ•˜๋Š” ์ƒํƒœ๋ณ€์ˆ˜: MySQL์—”์ง„์ด ๊ฐ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์—๊ฒŒ ๋ณด๋‚ธ ๋ช…๋ น์˜ ํšŸ์ˆ˜

๋‹ค๋ฅธ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์„ ์‚ฌ์šฉํ•˜๋Š” ํ…Œ์ด๋ธ”์ด๋ผ๋„ MySQL์—”์ง„ ์ฒ˜๋ฆฌ๋‚ด์šฉ์€ ๋Œ€๋ถ€๋ถ„ ๋™์ผํ•˜๋ฉฐ, ๋ฐ์ดํ„ฐ ์ฝ๊ธฐ/์“ฐ๊ธฐ ์˜์—ญ์˜ ์ฒ˜๋ฆฌ๋งŒ ์ฐจ์ด๊ฐ€ ์žˆ๋‹ค.

  • ์‹ค์งˆ์ ์ธ Group By๋‚˜ Order by ๋“ฑ ๋ณต์žกํ•œ ์ฒ˜๋ฆฌ๋Š” ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์˜์—ญ์ด ์•„๋‹Œ MySQL ์—”์ง„์˜ ์ฟผ๋ฆฌ ์‹คํ–‰๊ธฐ์—์„œ ์ฒ˜๋ฆฌ๋œ๋‹ค.

์ค‘์š”ํ•œ ๋‚ด์šฉ

  • ํ•˜๋‚˜์˜ ์ฟผ๋ฆฌ ์ž‘์—…์€ ์—ฌ๋Ÿฌ ํ•˜์œ„ ์ž‘์—…์œผ๋กœ ๋‚˜๋‰˜๋Š”๋ฐ, ๊ฐ ํ•˜์œ„ ์ž‘์—…์ด MySQL์—”์ง„์—์„œ ์ฒ˜๋ฆฌ๋˜๋Š”์ง€ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์—์„œ ์ฒ˜๋ฆฌ๋˜๋Š”์ง€ ๊ตฌ๋ถ„ํ•  ์ค„ ์•Œ์•„์•ผํ•œ๋‹ค.

MySQL์„œ๋ฒ„์—์„œ ์ง€์›๋˜๋Š” ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„ ๋ณด๊ธฐ

mysql> SHOW ENGINES;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.31 sec)

[Support ์ปฌ๋Ÿผ]

  • YES: MySQL ์„œ๋ฒ„์— ํ•ด๋‹น ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์ด ํฌํ•จ๋˜์–ด์žˆ๊ณ , ์‚ฌ์šฉ ๊ฐ€๋Šฅ์œผ๋กœ ํ™œ์„ฑํ™”๋œ ์ƒํƒœ์ž„
  • DEFAULT: YES์™€ ๋™์ผํ•œ ์ƒํƒœ์ด์ง€๋งŒ ํ•„์ˆ˜ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์ž„์„ ์˜๋ฏธ
    • ์ด ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์ด ์—†์œผ๋ฉด MySQL์ด ์‹œ์ž‘๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Œ์„ ์˜๋ฏธ
  • NO: ํ˜„์žฌ MySQL ์„œ๋ฒ„์— ํฌํ•จ๋˜์ง€ ์•Š์•˜์Œ์„ ์˜๋ฏธ
  • DISABLED: ํ˜„์žฌ MySQL ์„œ๋ฒ„์— ํฌํ•จ๋˜์—ˆ์ง€๋งŒ ํŒŒ๋ผ๋ฏธํ„ฐ์— ์˜ํ•ด ๋น„ํ™œ์„ฑํ™”๋œ ์ƒํƒœ

NO๋กœ ํ‘œ์‹œ๋œ ์Šคํ† ๋ฆฌ์ง€์—”์ง„์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด MySQL ์„œ๋ฒ„๋ฅผ ๋‹ค์‹œ ๋นŒ๋“œ(์ปดํŒŒ์ผ)ํ•ด์•ผํ•œ๋‹ค. ํ•˜์ง€๋งŒ ์„œ๋ฒ„๋งŒ ์ค€๋น„๋˜์–ด์žˆ๋‹ค๋ฉด ํ”Œ๋Ÿฌ๊ทธ์ธ ํ˜•ํƒœ๋กœ ๋นŒ๋“œ๋œ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋‹ค์šด๋กœ๋“œํ•ด์„œ ๋ผ์›Œ๋„ฃ์„ ์ˆ˜ ์žˆ๋‹ค.

ํ”Œ๋กœ๊ทธ์ธ ํ™•์ธ ์ฟผ๋ฆฌ

mysql> show plugins;
+----------------------------+----------+--------------------+---------+---------+
| Name                       | Status   | Type               | Library | License |
+----------------------------+----------+--------------------+---------+---------+
| binlog                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| mysql_native_password      | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
| mysql_old_password         | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
| sha256_password            | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
| MyISAM                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| MRG_MYISAM                 | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| MEMORY                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| CSV                        | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| ARCHIVE                    | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| InnoDB                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| INNODB_TRX                 | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_LOCKS               | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_LOCK_WAITS          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP                 | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_RESET           | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMPMEM              | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMPMEM_RESET        | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_PER_INDEX       | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_PAGE         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_PAGE_LRU     | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_POOL_STATS   | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_METRICS             | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_DELETED          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_BEING_DELETED    | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_CONFIG           | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_INDEX_CACHE      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_INDEX_TABLE      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLES          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLESTATS      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_INDEXES         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_COLUMNS         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FIELDS          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FOREIGN         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FOREIGN_COLS    | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLESPACES     | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_DATAFILES       | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| BLACKHOLE                  | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| FEDERATED                  | DISABLED | STORAGE ENGINE     | NULL    | GPL     |
| PERFORMANCE_SCHEMA         | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| partition                  | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
+----------------------------+----------+--------------------+---------+---------+
42 rows in set (0.56 sec)
  • MySQL ์„œ๋ฒ„๋Š” ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„ ๋ฟ ์•„๋‹ˆ๋ผ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ํ”Œ๋Ÿฌ๊ทธ์ธ์œผ๋กœ ์ง€์›ํ•œ๋‹ค.

4.1.5 ์ปดํฌ๋„ŒํŠธ

MySQL 8.0 ๋ถ€ํ„ฐ๋Š” ๊ธฐ์กด ํ”Œ๋Ÿฌ๊ทธ์ธ ์•„ํ‚คํ…์ฒ˜๋ฅผ ๋Œ€์ฒดํ•˜๊ธฐ ์œ„ํ•ด ์ปดํฌ๋„ŒํŠธ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์ง€์›ํ•œ๋‹ค.

ํ”Œ๋Ÿฌ๊ทธ์ธ์€ ์•„๋ž˜์™€ ๊ฐ™์€ ๋‹จ์ ์ด ์žˆ์œผ๋ฉฐ, ์ปดํฌ๋„ŒํŠธ๋Š” ํ•ด๋‹น ๋‹จ์ ์„ ๋ณด์™„ํ•˜์˜€๋‹ค.

  • ํ”Œ๋Ÿฌ๊ทธ์ธ์€ ์˜ค์ง MySQL ์„œ๋ฒ„์™€ ์ธํ„ฐํŽ˜์ด์Šค ํ•  ์ˆ˜ ์žˆ๊ณ , ํ”Œ๋Ÿฌ๊ทธ์ธ๋ผ๋ฆฌ๋Š” ํ†ต์‹ ํ•  ์ˆ˜ ์—†์Œ
  • ํ”Œ๋Ÿฌ๊ทธ์ธ์€ MySQL ์„œ๋ฒ„์˜ ๋ณ€์ˆ˜๋‚˜ ํ•จ์ˆ˜๋ฅผ ์ง์ ‘ ํ˜ธ์ถœํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์•ˆ์ „ํ•˜์ง€ ์•Š์Œ(์บก์Šํ™” ์•ˆ๋จ)
  • ํ”Œ๋Ÿฌ๊ทธ์ธ์€ ์ƒํ˜ธ ์˜์กด ๊ด€๊ณ„๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์—†์–ด์„œ ์ดˆ๊ธฐํ™”๊ฐ€ ์–ด๋ ค์›€

MySQL 5.7๋ฒ„์ „๊นŒ์ง€๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ ๊ฒ€์ฆ ๊ธฐ๋Šฅ์ด ํ”Œ๋Ÿฌ๊ทธ์ธ ํ˜•ํƒœ๋กœ ์ œ๊ณต๋˜์—ˆ์ง€๋งŒ, MySQL 8.0์€ ์ปดํฌ๋„ŒํŠธ๋กœ ๊ฐœ์„ ๋˜์—ˆ๋‹ค.

// validate_password ์„ค์น˜
install component 'file://component_validate_password';

// ์„ค์น˜๋œ ์ปดํฌ๋„ŒํŠธ ํ™•์ธ
select * from sql.componet; 

์ปดํฌ๋„ŒํŠธ ์‚ฌ์šฉ์ „์—” ๊ด€๋ จ ๋ฉ”๋‰ด์–ผ์„ ์‚ดํŽด๋ณด์ž.

4.1.6 ์ฟผ๋ฆฌ ์‹คํ–‰ ๊ตฌ์กฐ

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-04-17 แ„‹แ…ฉแ„’แ…ฎ 8 32 21

์ฟผ๋ฆฌ ์‹คํ–‰ ๊ด€์ ์—์„œ์˜ MySQL ๊ตฌ์กฐ

4.1.6.1 ์ฟผ๋ฆฌ ํŒŒ์„œ

  • ์‚ฌ์šฉ์ž ์š”์ฒญ์œผ๋กœ ๋“ค์–ด์˜จ ์ฟผ๋ฆฌ๋ฅผ ํ† ํฐ(MySQL์ด ์ธ์‹ํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ์†Œ ๋‹จ์œ„์˜ ์–ดํœ˜๋‚˜ ๊ธฐํ˜ธ)๋กœ ๋ถ„๋ฆฌํ•ด ํŠธ๋ฆฌํ˜•ํƒœ์˜ ๊ตฌ์กฐ๋กœ ๋งŒ๋“ค์–ด๋‚ด๋Š” ์ž‘์—…์„ ํ•œ๋‹ค.
  • ์ด ๊ณผ์ •์—์„œ ์ฟผ๋ฆฌ์˜ ๊ธฐ๋ณธ ๋ฌธ๋ฒ• ์˜ค๋ฅ˜๋ฅผ ๋ฐœ๊ฒฌํ•˜๊ณ  ์‚ฌ์šฉ์ž์—๊ฒŒ ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.

4.1.6.2 ์ „์ฒ˜๋ฆฌ๊ธฐ

  • ํŒŒ์„œ ๊ณผ์ •์—์„œ ๋งŒ๋“ค์–ด์ง„ ํŒŒ์„œ ํŠธ๋ฆฌ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ฟผ๋ฆฌ์˜ ๊ตฌ์กฐ์  ๋ฌธ์ œ์ ์„ ํ™•์ธํ•œ๋‹ค.
  • ์ด ๊ณผ์ •์—์„œ ๊ฐ ํ† ํฐ์„ ํ…Œ์ด๋ธ” ์ด๋ฆ„, ์นผ๋Ÿผ ์ด๋ฆ„ ๋˜๋Š” ๋‚ด์žฅ ํ•จ์ˆ˜์™€ ๊ฐ™์€ ๊ฐœ์ฒด๋ฅผ ๋งคํ•‘ํ•ด ๊ฐ์ฒด์˜ ์กด์žฌ ์—ฌ๋ถ€์™€ ๊ฐ์ฒด์˜ ์ ‘๊ทผ ๊ถŒํ•œ๋“ฑ์„ ํ™•์ธํ•œ๋‹ค.
  • ์‹ค์ œ ์กด์žฌํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ ๊ถŒํ•œ์ƒ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ๊ฐœ์ฒด์˜ ํ† ํฐ์€ ์ด ๋‹จ๊ณ„์—์„œ ๊ฑธ๋Ÿฌ์ง„๋‹ค.

4.1.6.3 ์˜ตํ‹ฐ๋งˆ์ด์ €

  • ์‚ฌ์šฉ์ž ์š”์ฒญ์œผ๋กœ ๋“ค์–ด์˜จ ์ฟผ๋ฆฌ๋ฅผ ์ €๋ ดํ•œ ๋น„์šฉ์œผ๋กœ ๊ฐ€์žฅ ๋น ๋ฅด๊ฒŒ ์ฒ˜๋ฆฌํ• ์ง€๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ์—ญํ•  (DBMS ๋‘๋‡Œ)
  • ์–ด๋–ป๊ฒŒํ•˜๋ฉด ์˜ตํ‹ฐ๋งˆ์ด์ €๊ฐ€ ๋” ๋‚˜์€ ์„ ํƒ์„ ํ•˜๋„๋ก ์œ ๋„ํ•˜๋Š”๊ฐ€๋ฅผ ์•„๋Š”๊ฒƒ์ด ์ค‘์š”.

4.1.6.4 ์‹คํ–‰์—”์ง„

  • ์˜ตํ‹ฐ๋งˆ์ด์ €๊ฐ€ ๋‘๋‡Œ๋ผ๋ฉด ์‹คํ–‰ ์—”์ง„๊ณผ ํ•ธ๋“ค๋Ÿฌ๋Š” ์†๊ณผ ๋ฐœ์ด๋‹ค.
  • ์˜ตํ‹ฐ๋งˆ์ด์ € = ํšŒ์‚ฌ ๊ฒฝ์˜์ง„, ์‹คํ–‰ ์—”์ง„ = ์ค‘๊ฐ„ ๊ด€๋ฆฌ์ž, ํ•ธ๋“ค๋Ÿฌ = ์‹ค๋ฌด์ž

์˜ตํ‹ฐ๋งˆ์ด์ €๊ฐ€ GROUP BY๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์ž„์‹œ ํ…Œ์ด๋ธ”์„ ์‚ฌ์šฉํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ๋‹ค๋ฉด?

  1. ์‹คํ–‰ ์—”์ง„์ด ํ•ธ๋“ค๋Ÿฌ์—๊ฒŒ ์ž„์‹œ ํ…Œ์ด๋ธ”์„ ๋งŒ๋“ค๋ผ๊ณ  ์š”์ฒญ
  2. ๋‹ค์‹œ ์‹คํ–‰ ์—”์ง„์€ WHERE ์ ˆ์— ์ผ์น˜ํ•˜๋Š” ๋ ˆ์ฝ”๋“œ๋ฅผ ์ฝ์–ด์˜ค๋ผ๊ณ  ํ•ธ๋“ค๋Ÿฌ์—๊ฒŒ ์š”์ฒญ
  3. ์ฝ์–ด์˜จ ๋ ˆ์ฝ”๋“œ๋“ค์„ 1๋ฒˆ์—์„œ ์ค€๋น„ํ•œ ์ž„์‹œ ํ…Œ์ด๋ธ”๋กœ ์ €์žฅํ•˜๋ผ๊ณ  ๋‹ค์‹œ ํ•ธ๋“ค๋Ÿฌ์—๊ฒŒ ์š”์ฒญ
  4. ๋ฐ์ดํ„ฐ๊ฐ€ ์ค€๋น„๋œ ์ž„์‹œ ํ…Œ์ด๋ธ”์—์„œ ํ•„์š”ํ•œ ๋ฐฉ์‹์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด ์˜ค๋ผ๊ณ  ํ•ธ๋“ค๋Ÿฌ์—๊ฒŒ ๋‹ค์‹œ ์š”์ฒญ
  5. ์ตœ์ •์ ์œผ๋กœ ์‹คํ–‰ ์—”์ง„์€ ๊ฒฐ๊ณผ๋ฅผ ์‚ฌ์šฉ์ž๋‚˜ ๋‹ค๋ฅธ ๋ชจ๋“ˆ๋กœ ๋„˜๊น€

์‹คํ–‰ ์—”์ง„์€ ๋งŒ๋“ค์–ด์ง„ ๊ณ„ํš๋Œ€๋กœ ๊ฐ ํ•ธ๋“ค๋Ÿฌ์—๊ฒŒ ์š”์ฒญํ•ด์„œ ๋ฐ›์€ ๊ฒฐ๊ณผ๋ฅผ ๋‹ค๋ฅธ ํ•ธ๋“ค๋Ÿฌ ์š”์ฒญ์˜ ์ž…๋ ฅ์œผ๋กœ ์—ฐ๊ฒฐํ•˜๋Š” ์—ญํ• ์„ ์ˆ˜ํ–‰ํ•œ๋‹ค.

4.1.6.5 ํ•ธ๋“ค๋Ÿฌ(์Šคํ† ๋ฆฌ์ง€ ์—”์ง„)

  • ํ•ธ๋“ค๋Ÿฌ๋Š” MySQL ์„œ๋ฒ„ ๊ฐ€์žฅ ๋ฐ‘๋‹จ์—์„œ ์‹คํ–‰ ์—”์ง„์˜ ์š”์ฒญ์— ๋”ฐ๋ผ ๋ฐ์ดํ„ฐ๋ฅผ ๋””์Šคํฌ๋กœ ์ €์žฅํ•˜๊ณ  ์ฝ์–ด์˜ค๋Š” ์—ญํ• ์„ ๋‹ด๋‹นํ•œ๋‹ค.
  • ๊ฒฐ๊ตญ ํ•ธ๋“ค๋Ÿฌ๋Š” ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์„ ์˜๋ฏธํ•œ๋‹ค.

4.1.7 ๋ณต์ œ

  • MySQL ์„œ๋ฒ„์—์„œ ๋ณต์ œ(Replication)์€ ๋งค์šฐ ์ค‘์š”ํ•œ ์—ญํ• ์„ ๋‹ด๋‹นํ•œ๋‹ค. (16์žฅ์—์„œ ์ž์„ธํžˆ)

4.1.8 ์ฟผ๋ฆฌ ์บ์‹œ

  • MySQL ์„œ๋ฒ„์—์„œ ์ฟผ๋ฆฌ ์บ์‹œ(Query Cache)๋Š” ๋น ๋ฅธ ์‘๋‹ต์„ ํ•„์š”๋กœ ํ•˜๋Š” ์›น์—์„œ ๋งค์šฐ ์ค‘์š”ํ•œ ์—ญํ• ์„ ๋‹ด๋‹นํ–ˆ๋‹ค.
  • ์ฟผ๋ฆฌ ์บ์‹œ๋Š” SQL ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ๋ฉ”๋ชจ๋ฆฌ์— ์บ์‹œํ•˜๊ณ , ๋™์ผ SQL ์ฟผ๋ฆฌ๊ฐ€ ์‹คํ–‰๋˜๋ฉด ์ฆ‰์‹œ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
  • ํ•˜์ง€๋งŒ ํ…Œ์ด๋ธ” ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด ์ €์žฅ๋œ ๊ฒฐ๊ณผ ์ค‘ ๋ณ€๊ฒฝ๋œ ํ…Œ์ด๋ธ”๊ณผ ๊ด€๋ จ๋œ ๊ฒƒ๋“ค์€ ๋ชจ๋‘ ์‚ญ์ œํ•ด์•ผ ํ–ˆ๋‹ค. (Invalidate)
    • ์ด๋Š” ์‹ฌ๊ฐํ•œ ๋™์‹œ ์ฒ˜๋ฆฌ ์„ฑ๋Šฅ ์ €ํ•˜์™€ ๋งŽ์€ ๋ฒ„๊ทธ์˜ ์›์ธ์ด ๋˜๊ธฐ๋„ ํ–ˆ๋‹ค.
  • ๊ฒฐ๊ตญ 8.0์œผ๋กœ ์˜ฌ๋ผ์˜ค๋ฉด์„œ ์ฟผ๋ฆฌ ์บ์‹œ๋Š” ๊ธฐ๋Šฅ์—์„œ ์™„์ „ํžˆ ์ œ๊ฑฐ๋˜์—ˆ๋‹ค.

4.1.9 ์Šค๋ ˆ๋“œ ํ’€

  • ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ์—๋””์…˜์€ ์Šค๋ ˆ๋“œํ’€ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜์ง€๋งŒ, ์ปค๋ฎค๋‹ˆํ‹ฐ ์—๋””์…˜์€ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.
  • ๋”ฐ๋ผ์„œ ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ๋Œ€์‹  Percona Server์—์„œ ์ œ๊ณตํ•˜๋Š” ์Šค๋ ˆ๋“œ ํ’€ ๊ธฐ๋Šฅ์„ ์‚ดํŽด๋ณด์ž.

์—”ํ„ฐํ”„๋ผ์ด์ฆˆ๋Š” ์Šค๋ ˆ๋“œํ’€๊ธฐ๋Šฅ์ด ์„œ๋ฒ„์— ๋‚ด์žฅ๋˜์–ด์žˆ์ง€๋งŒ, Percona Server๋Š” ํ”Œ๋Ÿฌ๊ทธ์ธ ํ˜•ํƒœ๋กœ ์ž‘๋™ํ•œ๋‹ค.
๋งŒ์•ฝ ์ปค๋ฎค๋‹ˆํ‹ฐ์—์„œ๋„ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•œ๋‹ค๋ฉด, Percona Server์—์„œ ์Šค๋ ˆ๋“œ ํ’€ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์„ค์น˜ํ•ด์„œ ์‚ฌ์šฉํ•˜๋ฉด๋œ๋‹ค.

์Šค๋ ˆ๋“œ ํ’€์€ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์Šค๋ ˆ๋“œ ๊ฐœ์ˆ˜๋ฅผ ์ค„์—ฌ์„œ, ๋™์‹œ์— ์ฒ˜๋ฆฌ๋˜๋Š” ์š”์ฒญ์ด ๋งŽ๋‹คํ•˜๋”๋ผ๋„ MySQL์„œ๋ฒ„์˜ CPU๊ฐ€ ์ œํ•œ๋œ ๊ฐœ์ˆ˜์˜ ์Šค๋ ˆ๋“œ ์ฒ˜๋ฆฌ์—๋งŒ ์ง‘์ค‘ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด ์„œ๋ฒ„์˜ ์ž์› ์†Œ๋ชจ๋ฅผ ์ค„์ด๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ด๋‹ค.

  • ์‚ฌ์‹ค ์Šค๋ ˆ๋“œํ’€์ด ๋ˆˆ์— ๋„๋Š” ์„ฑ๋Šฅํ–ฅ์ƒ์„ ๋ณด์—ฌ์ฃผ์ง„ ์•Š๋Š”๋‹ค.
  • ๋™์‹œ์— ์‹คํ–‰์ค‘์ธ ์Šค๋ ˆ๋“œ๋“ค์„ CPU๊ฐ€ ์ตœ๋Œ€ํ•œ ์ž˜ ์ฒ˜๋ฆฌํ•ด๋‚ผ ์ˆ˜์ค€์œผ๋กœ ์ค„์—ฌ์„œ ๋นจ๋ฆฌ ์ฒ˜๋ฆฌํ•˜๊ฒŒ ํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค.
  • ๋”ฐ๋ผ์„œ ์Šค์ผ€์ค„๋ง ๊ณผ์ •์— CPU์‹œ๊ฐ„์„ ์ œ๋Œ€๋กœ ํ™•๋ณดํ•˜์ง€ ๋ชปํ•œ๊ฒฝ์šฐ ์ฟผ๋ฆฌ ์ฒ˜๋ฆฌ๊ฐ€ ๋” ๋Š๋ ค์งˆ ์ˆ˜ ๋„ ์žˆ๋‹ค.
  • ๋ฌผ๋ก  ์ œํ•œ๋œ ์ˆ˜์˜ ์Šค๋ ˆ๋“œ๋งŒ์œผ๋กœ CPU๊ฐ€ ์ฒ˜๋ฆฌํ•œ๋‹ค๋ฉด, CPU์˜ ํ”„๋กœ์„ธ์„œ ์นœํ™”๋„(Processor affinity)๋„ ๋†’์ด๊ณ  OS์ž…์žฅ์—์„œ ๋ถˆํ•„์š”ํ•œ ์ปจํ…์ŠคํŠธ ์Šค์œ„์น˜๋ฅผ ์ค„์—ฌ ์˜ค๋ฒ„ํ—ค๋“œ๋ฅผ ๋‚ฎ์ถœ ์ˆ˜ ์žˆ๋‹ค.

โ“ CPU์˜ ํ”„๋กœ์„ธ์„œ ์นœํ™”๋„๊ฐ€ ๋ญ์ง€?

Percona Server ์Šค๋ ˆ๋“œํ’€

  • ๊ธฐ๋ณธ์ ์œผ๋กœ CPU ์ฝ”์–ด์˜ ๊ฐœ์ˆ˜๋งŒํผ ์Šค๋ ˆ๋“œ ๊ทธ๋ฃน์„ ์ƒ์„ฑํ•œ๋‹ค. (thread_pool_size ์‹œ์Šคํ…œ ๋ณ€์ˆ˜๋กœ ์กฐ์ • ๊ฐ€๋Šฅ)
    • ์ผ๋ฐ˜์ ์œผ๋กœ CPU ์ฝ”์–ด์˜ ๊ฐœ์ˆ˜์™€ ๋งž์ถ”๋Š” ๊ฒƒ์ด CPU ํ”„๋กœ์„ธ์„œ ์นœํ™”๋„๋ฅผ ๋†’์ด๋Š”๋ฐ ์ข‹๋‹ค.
  • MySQL ์„œ๋ฒ„๊ฐ€ ์ฒ˜๋ฆฌํ•ด์•ผ ํ•  ์š”์ฒญ์ด ์ƒ๊ธฐ๋ฉด ์Šค๋ ˆ๋“œ ํ’€๋กœ ์ฒ˜๋ฆฌ๋ฅผ ์ด๊ด€ํ•œ๋‹ค.
  • ๋งŒ์•ฝ ์Šค๋ ˆ๋“œ ํ’€์ด ์ฒ˜๋ฆฌ์ค‘์ธ ์ž‘์—…์ด ์žˆ๋Š” ๊ฒฝ์šฐ thread_pool_oversubscribe(๊ธฐ๋ณธ๊ฐ’ 3)์— ์„ค์ •๋œ ๊ฐœ์ˆ˜๋งŒํผ ์ถ”๊ฐ€๋กœ ๋” ๋ฐ›์•„๋“ค์—ฌ ์ฒ˜๋ฆฌํ•œ๋‹ค.
    • ์ด ๊ฐ’์ด ๋„ˆ๋ฌด ํฌ๋ฉด ์Šค์ผ€์ค„๋งํ•ด์•ผํ•  ์Šค๋ ˆ๋“œ๊ฐ€ ๋งŽ์•„์ ธ ์Šค๋ ˆ๋“œ ํ’€์ด ๋น„ํšจ์œจ์ ์œผ๋กœ ์ž‘๋™ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ์Šค๋ ˆ๋“œ ๊ทธ๋ฃน์˜ ๋ชจ๋“  ์Šค๋ ˆ๋“œ๊ฐ€ ์ผ์„ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ๋‹ค๋ฉด, ์Šค๋ ˆ๋“œ ํ’€์€ ํ•ด๋‹น ์Šค๋ ˆ๋“œ ๊ทธ๋ฃน์— ์ƒˆ๋กœ์šด ์ž‘์—… ์Šค๋ ˆ๋“œ(Worker thread)๋ฅผ ์ถ”๊ฐ€ํ• ์ง€, ์•„๋‹ˆ๋ฉด ๊ธฐ์กด ์ž‘์—… ์Šค๋ ˆ๋“œ๊ฐ€ ์™„๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ๋Œ€๊ธฐ ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•ด์•ผํ•œ๋‹ค.
    • ์Šค๋ ˆ๋“œ ํ’€์˜ ํƒ€์ด๋จธ ์Šค๋ ˆ๋“œ๋Š” ์ฃผ๊ธฐ์ ์œผ๋กœ ์Šค๋ ˆ๋“œ ๊ทธ๋ฃน์˜ ์ƒํƒœ๋ฅผ ์ฒดํฌํ•ด์„œ thread_pool_stall_limit์— ์ •์˜๋œ ๋ฐ€๋ฆฌ์ดˆ๋งŒํผ ์Šค๋ ˆ๋“œ๊ฐ€ ์ž‘์—…์„ ๋๋‚ด์ง€ ๋ชปํ•˜๋ฉด ์ƒˆ๋กœ์šด ์Šค๋ ˆ๋“œ๋ฅผ ์ƒ์„ฑํ•ด ๊ทธ๋ฃน์— ์ถ”๊ฐ€ํ•œ๋‹ค.
    • ์ „์ฒด ์Šค๋ ˆ๋“œ ํ’€์— ์žˆ๋Š” ์Šค๋ ˆ๋“œ์˜ ๊ฐœ์ˆ˜๋Š” thread_pool_max_threads ๊ฐœ์ˆ˜๋ฅผ ๋„˜๊ธธ ์ˆ˜ ์—†๋‹ค.

์ฆ‰, ๋ชจ๋“  ์Šค๋ ˆ๋“œ ๊ทธ๋ฃน์˜ ์Šค๋ ˆ๋“œ๊ฐ€ ๊ฐ์ž ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ๋Š” ์ƒํƒœ์—์„œ ์ƒˆ๋กœ์šด ์š”์ฒญ์ด ๋“ค์–ด์˜ค๋”๋ผ๋„ ์Šค๋ ˆ๋“œ ํ’€์€ thread_pool_stall_limit ์‹œ๊ฐ„ ๋™์•ˆ ๊ธฐ๋‹ค๋ ค์•ผ๋งŒ ์ƒˆ๋กœ์šด ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.

  • ๋”ฐ๋ผ์„œ ์‘๋‹ต ์‹œ๊ฐ„์ด ์•„์ฃผ ๋ฏผ๊ฐํ•œ ์„œ๋น„์Šค๋ผ๋ฉด thread_pool_stall_limit๋ฅผ ์ ์ ˆํžˆ ๋‚ฎ์ถฐ ์„ค์ •ํ•ด์•ผํ•˜์ง€๋งŒ, 0์— ๊ฐ€๊นŒ์šด ๊ฐ’์œผ๋กœ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์€ ๊ถŒ์žฅํ•˜์ง€ ์•Š๋Š”๋‹ค. โžก๏ธ ์ด๋Ÿด๊ฒฝ์šฐ ์Šค๋ ˆ๋“œ ํ’€์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๊ฒŒ ๋‚˜์Œ

โ“ ์Šค๋ ˆ๋“œ ๊ทธ๋ฃน, ์Šค๋ ˆ๋“œ ํ’€์˜ ์ฐจ์ด๊ฐ€ ๋ญ์ง€?

Percona Server ์Šค๋ ˆ๋“œํ’€์˜ ํ

  • Percona Server ์Šค๋ ˆ๋“œํ’€ ํ”Œ๋Ÿฌ๊ทธ์ธ์€ ์„ ์ˆœ์œ„ ํ์™€ ํ›„์ˆœ์œ„ ํ๋ฅผ ์ด์šฉํ•ด ํŠน์ • ํŠธ๋žœ์žญ์…˜์ด๋‚˜ ์ฟผ๋ฆฌ๋ฅผ ์šฐ์„ ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค.
  • ๋จผ์ € ์‹œ์ž‘๋œ ํŠธ๋žœ์žญ์…˜ ๋‚ด ์†ํ•œ SQL์„ ๋นจ๋ฆฌ ์ฒ˜๋ฆฌํ•ด์ฃผ๋ฉด ํ•ด๋‹น ํŠธ๋žœ์žญ์…˜์ด ๊ฐ€์ง€๊ณ  ์žˆ๋˜ ์ž ๊ธˆ์ด ๋นจ๋ฆฌ ํ•ด์ œ๋˜๊ณ  ์ž ๊ธˆ ๊ฒฝํ•ฉ์„ ๋‚ฎ์ถฐ์„œ ์ „์ฒด์ ์ธ ์ฒ˜๋ฆฌ ์„ฑ๋Šฅ์„ ๋†’์ผ ์ˆ˜ ์žˆ๋‹ค.

โ“ ์ž ๊ธˆ ๊ฒฝํ•ฉ์ด ๋ญ์ง€?

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-04-17 แ„‹แ…ฉแ„’แ…ฎ 11 31 26

4.1.10 ํŠธ๋žœ์žญ์…˜ ์ง€์› ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ

ํ…Œ์ด๋ธ”์ด ๊นจ์กŒ๋‹ค?

  • ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„œ๋ฒ„์—์„œ ํ…Œ์ด๋ธ” ๊ตฌ์กฐ ์ •๋ณด์™€ ์Šคํ† ์–ด๋“œ ํ”„๋กœ๊ทธ๋žจ๋“ฑ์˜ ์ •๋ณด๋ฅผ ๋”•์…”๋„ˆ๋ฆฌ or ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ผ๊ณ  ํ•œ๋‹ค.
  • MySQL 5.7๋ฒ„์ „๊นŒ์ง€ ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋ฅผ FRM ํŒŒ์ผ์— ์ €์žฅํ•˜๊ณ  ์ผ๋ถ€ ํ”„๋กœ๊ทธ๋žจ๋˜ํ•œ ํŒŒ์ผ๋กœ ๊ด€๋ฆฌํ–ˆ๋‹ค.
  • ํ•˜์ง€๋งŒ ํŒŒ์ผ ๊ธฐ๋ฐ˜์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋Š” ์ƒ์„ฑ/๋ณ€๊ฒฝ ์‹œ ํŠธ๋žœ์žญ์…•์„ ์ง€์›ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์ƒ์„ฑ/๋ณ€๊ฒฝ ์‹œ ์„œ๋ฒ„๊ฐ€ ๋น„์ •์ƒ์ ์œผ๋กœ ์ข…๋ฃŒ๋˜๋ฉด ์ผ๊ด€๋˜์ง€ ์•Š์€ ์ƒํƒœ๋กœ ๋‚จ๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค.
  • ์ด๋ฅผ DB๋‚˜ ํ…Œ์ด๋ธ”์ด ๊นจ์กŒ๋‹ค๋ผ๊ณ  ํ‘œํ˜„ํ•œ๋‹ค.

InnoDB ์‹œ์Šคํ…œ ํ…Œ์ด๋ธ”

  • MySQL8.0๋ถ€ํ„ฐ ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋ถ€ InnoDB์˜ ํ…Œ์ด๋ธ”๋กœ ์ €์žฅํ•˜๋„๋ก ๊ฐœ์„ ํ–ˆ๋‹ค.
  • MySQL ์„œ๋ฒ„๊ฐ€ ์ž‘๋™ํ•˜๋Š”๋ฐ ๊ธฐ๋ณธ์ ์œผ๋กœ ํ•„์š”ํ•œ ํ…Œ์ด๋ธ”์„ ๋ฌถ์–ด ์‹œ์Šคํ…œ ํ…Œ์ด๋ธ”์ด๋ผ๊ณ  ํ•œ๋‹ค.
    • ex) ์‚ฌ์šฉ์ž ์ธ์ฆ๊ณผ ๊ถŒํ•œ์— ๊ด€๋ จ๋œ ํ…Œ์ด๋ธ”
  • ์‹œ์Šคํ…œ ํ…Œ์ด๋ธ”๊ณผ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋ชจ๋‘ ๋ชจ์•„ mysql DB์— ์ €์žฅํ•˜๊ณ  ์žˆ๋‹ค.
  • mysql DB๋Š” ํ†ต์งธ๋กœ mysql.ibd๋ผ๋Š” ์ด๋ฆ„์˜ ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค์— ์ €์žฅ๋œ๋‹ค.
  • ์ด๋ฅผ ํ†ตํ•ด ์Šคํ‚ค๋งˆ ๋ณ€๊ฒฝ ์ž‘์—… ์ค‘ MySQL ์„œ๋ฒ„๊ฐ€ ๋น„์ •์ƒ์ ์œผ๋กœ ์ข…๋ฃŒ๋˜์–ด๋„ ์Šคํ‚ค๋งˆ ๋ณ€๊ฒฝ์€ ์™„์ „ํ•œ ์„ฑ๊ณต ๋˜๋Š” ์™„์ „ํ•œ ์‹คํŒจ๋กœ ์ •๋ฆฌ๋œ๋‹ค.

information_schema

  • ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฅผ mysql DB์— ์ €์žฅํ•œ๋‹ค๊ณ  ํ•˜์ง€๋งŒ, ์‹ค์ œ ํ…Œ์ด๋ธ” ๋ชฉ๋ก์„ ์‚ดํŽด๋ณด๋ฉด ๋ณด์ด์ง€ ์•Š์„ ๊ฒƒ์ด๋‹ค.
    • ์‚ฌ์šฉ์ž๊ฐ€ ์ˆ˜์ •ํ•˜์ง€ ๋ชปํ•˜๊ฒŒ ๋ณด์—ฌ์ฃผ์ง€ ์•Š์ง€๋งŒ ์‹ค์ œ๋กœ ์กด์žฌํ•œ๋‹ค.
  • ๋Œ€์‹  information_schema์—์„œ TABLES ํ…Œ์ด๋ธ”์„ ์ œ๊ณตํ•ด์ค€๋‹ค.
    • ์ด๋Š” mysql DB์˜ tables๋ผ๋Š” ์ด๋ฆ„์˜ ํ…Œ์ด๋ธ”์„ ์ฐธ์กฐํ•˜๊ณ  ์žˆ๋Š” ๋ทฐ์ด๋‹ค.
mysql> select * from information_schema.tables limit 10;
+---------------+--------------------+---------------------------------------+-------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------------+
| TABLE_CATALOG | TABLE_SCHEMA       | TABLE_NAME                            | TABLE_TYPE  | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME         | UPDATE_TIME         | CHECK_TIME | TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+---------------+--------------------+---------------------------------------+-------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------------+
| def           | information_schema | CHARACTER_SETS                        | SYSTEM VIEW | MEMORY |      10 | Fixed      |       NULL |            384 |           0 |        16434816 |            0 |         0 |           NULL | 2024-04-17 23:53:11 | NULL                | NULL       | utf8_general_ci |     NULL | max_rows=43690 |               |
| def           | information_schema | COLLATIONS                            | SYSTEM VIEW | MEMORY |      10 | Fixed      |       NULL |            231 |           0 |        16704765 |            0 |         0 |           NULL | 2024-04-17 23:53:11 | NULL                | NULL       | utf8_general_ci |     NULL | max_rows=72628 |               |
| def           | information_schema | COLLATION_CHARACTER_SET_APPLICABILITY | SYSTEM VIEW | MEMORY |      10 | Fixed      |       NULL |            195 |           0 |        16357770 |            0 |         0 |           NULL | 2024-04-17 23:53:11 | NULL                | NULL       | utf8_general_ci |     NULL | max_rows=86037 |               |
| def           | information_schema | COLUMNS                               | SYSTEM VIEW | MyISAM |      10 | Dynamic    |       NULL |              0 |           0 | 281474976710655 |         1024 |         0 |           NULL | 2024-04-17 23:53:11 | 2024-04-17 23:53:11 | NULL       | utf8_general_ci |     NULL | max_rows=2794  |               |
| def           | information_schema | COLUMN_PRIVILEGES                     | SYSTEM VIEW | MEMORY |      10 | Fixed      |       NULL |           2565 |           0 |        16757145 |            0 |         0 |           NULL | 2024-04-17 23:53:11 | NULL                | NULL       | utf8_general_ci |     NULL | max_rows=6540  |               |
| def           | information_schema | ENGINES                               | SYSTEM VIEW | MEMORY |      10 | Fixed      |       NULL |            490 |           0 |        16574250 |            0 |         0 |           NULL | 2024-04-17 23:53:11 | NULL                | NULL       | utf8_general_ci |     NULL | max_rows=34239 |               |
| def           | information_schema | EVENTS                                | SYSTEM VIEW | MyISAM |      10 | Dynamic    |       NULL |              0 |           0 | 281474976710655 |         1024 |         0 |           NULL | 2024-04-17 23:53:11 | 2024-04-17 23:53:11 | NULL       | utf8_general_ci |     NULL | max_rows=619   |               |
| def           | information_schema | FILES                                 | SYSTEM VIEW | MEMORY |      10 | Fixed      |       NULL |           2659 |           0 |        16743723 |            0 |         0 |           NULL | 2024-04-17 23:53:11 | NULL                | NULL       | utf8_general_ci |     NULL | max_rows=6309  |               |
| def           | information_schema | GLOBAL_STATUS                         | SYSTEM VIEW | MEMORY |      10 | Fixed      |       NULL |           3268 |           0 |        16755036 |            0 |         0 |           NULL | 2024-04-17 23:53:11 | NULL                | NULL       | utf8_general_ci |     NULL | max_rows=5133  |               |
| def           | information_schema | GLOBAL_VARIABLES                      | SYSTEM VIEW | MEMORY |      10 | Fixed      |       NULL |           3268 |           0 |        16755036 |            0 |         0 |           NULL | 2024-04-17 23:53:11 | NULL                | NULL       | utf8_general_ci |     NULL | max_rows=5133  |               |
+---------------+--------------------+---------------------------------------+-------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------------+
10 rows in set (0.07 sec)
mysql> select * from mysql.tables;
ERROR 1146 (42S02): Table 'mysql.tables' doesn't exist

์ฑ…์—์„œ๋Š” ์ ‘๊ทผ์ด ๊ฑฐ์ ˆ๋จ์ด๋ผ๊ณ  ์ถœ๋ ฅ๋œ๋‹ค๊ณ ํ•˜์ง€๋งŒ ๋‚˜๋Š” ์—†๋‹ค๊ณ  ๋‚˜์˜จ๋‹ค.

EROR 3554 (HY000): Access to data dictionary table 'mysql. tables' is rejected.

InnoDB์™ธ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„

  • InnoDB์™ธ MyISAM, CSV ๋“ฑ์˜ ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์„ ์‚ฌ์šฉํ•˜๋Š” ํ…Œ์ด๋ธ”๋“ค์€ SDI(Serialized Dictionary Information)ํŒŒ์ผ์„ ์‚ฌ์šฉํ•œ๋‹ค.
  • SDI๋Š” ๊ธฐ์กด์— *.FRM ํŒŒ์ผ๊ณผ ๋™์ผํ•œ ์—ญํ• ์„ ํ•œ๋‹ค.
  • SDI๋Š” ์ด๋ฆ„ ๊ทธ๋Œ€๋กœ ์ง๋ ฌํ™”๋ฅผ ์œ„ํ•œ ํฌ๋งท์ด๋ฏ€๋กœ, InnoDB ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋„ SDI๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ๋‹ค.