MySQL 8.0 의 새로운 특성 분석-사무 적 데이터 사전 과 원자 DDL

머리말
사무 적 데이터 사전 과 원자 DDL 은 MySQL 8.0 에서 출시 한 두 가지 매우 중요 한 새로운 특성 이다.이 두 가지 새로운 특성 을 한데 놓 은 이 유 는 이들 이 밀접 한 관 계 를 가지 기 때문이다.사무 적 데이터 사전 은 전제 이 고 원자 DDL 은 중요 한 응용 장면 이다.
MySQL 8.0 이전 데이터 사전
MySQL 8.0 이전의 데이터 사전 은 주로 다음 과 같은 세 부분 으로 구성 되 어 있 습 니 다.
(1)운영 체제 파일
db.opt:데이터베이스 메타 데이터 정보
frm:메타 데이터 정보
par:표 파 티 션 메타 데이터 정보
TRN/TRG:트리거 메타 데이터 정보
ddl_log.log:DDL 과정 에서 발생 하 는 메타 데이터 정보
(2)mysql 라 이브 러 리 의 비 InnoDB 시스템 테이블

mysql> select table_schema,table_name,table_type,engine from information_schema.tables where table_schema='mysql' and engine<>'InnoDB';
+--------------+------------------+------------+--------+
| table_schema | table_name    | table_type | engine |
+--------------+------------------+------------+--------+
| mysql    | columns_priv   | BASE TABLE | MyISAM |
| mysql    | db        | BASE TABLE | MyISAM |
| mysql    | event      | BASE TABLE | MyISAM |
| mysql    | func       | BASE TABLE | MyISAM |
| mysql    | general_log   | BASE TABLE | CSV  |
| mysql    | ndb_binlog_index | BASE TABLE | MyISAM |
| mysql    | proc       | BASE TABLE | MyISAM |
| mysql    | procs_priv    | BASE TABLE | MyISAM |
| mysql    | proxies_priv   | BASE TABLE | MyISAM |
| mysql    | slow_log     | BASE TABLE | CSV  |
| mysql    | tables_priv   | BASE TABLE | MyISAM |
| mysql    | user       | BASE TABLE | MyISAM |
+--------------+------------------+------------+--------+
12 rows in set (0.00 sec)
(3)mysql 라 이브 러 리 의 InnoDB 시스템 테이블

mysql> select table_schema,table_name,table_type,engine from information_schema.tables where table_schema='mysql' and engine='InnoDB';
+--------------+---------------------------+------------+--------+
| table_schema | table_name        | table_type | engine |
+--------------+---------------------------+------------+--------+
| mysql    | engine_cost        | BASE TABLE | InnoDB |
| mysql    | gtid_executed       | BASE TABLE | InnoDB |
| mysql    | help_category       | BASE TABLE | InnoDB |
| mysql    | help_keyword       | BASE TABLE | InnoDB |
| mysql    | help_relation       | BASE TABLE | InnoDB |
| mysql    | help_topic        | BASE TABLE | InnoDB |
| mysql    | innodb_index_stats    | BASE TABLE | InnoDB |
| mysql    | innodb_table_stats    | BASE TABLE | InnoDB |
| mysql    | plugin          | BASE TABLE | InnoDB |
| mysql    | server_cost        | BASE TABLE | InnoDB |
| mysql    | servers          | BASE TABLE | InnoDB |
| mysql    | slave_master_info     | BASE TABLE | InnoDB |
| mysql    | slave_relay_log_info   | BASE TABLE | InnoDB |
| mysql    | slave_worker_info     | BASE TABLE | InnoDB |
| mysql    | time_zone         | BASE TABLE | InnoDB |
| mysql    | time_zone_leap_second   | BASE TABLE | InnoDB |
| mysql    | time_zone_name      | BASE TABLE | InnoDB |
| mysql    | time_zone_transition   | BASE TABLE | InnoDB |
| mysql    | time_zone_transition_type | BASE TABLE | InnoDB |
+--------------+---------------------------+------------+--------+
19 rows in set (0.00 sec)
우 리 는 데이터 사전 이 여러 곳 에 분포 되 어 있 고 한편 으로 는 메타 데이터 의 통일 적 인 관리 에 불리 하 며 다른 한편 으로 는 데이터 의 불일치 가 발생 하기 쉽다 는 것 을 알 수 있다.(운영 체제 파일,비 InnoDB 시스템 표 는 모두 사 무 를 지원 하지 않 기 때문에 DDL 작업 을 수행 하면 ACID 를 보장 할 수 없다)
MySQL 8.0 데이터 사전
상기 문 제 를 해결 하기 위해 MySQL 8.0 은 데이터 사전 을 InnoDB 저장 엔진 저장 소 로 통일 적 으로 개선 하고 구체 적 으로 두 부분 으로 나 누 었 다.
(1)데이터 사전 표:가장 중요 한 메타 데이터 정 보 를 저장 하고 my sql 라 이브 러 리 에 있 으 며 my sql 공유 표 공간(my sql.ibd)에 저 장 됩 니 다.
(2)기타 시스템 표:보조 메타 데이터 정 보 를 저장 하고 my sql 라 이브 러 리 에 있 으 며 my sql 공유 표 공간(my sql.ibd)에 저장 합 니 다.
데이터 사전 표
데이터 사전 표 는 보이 지 않 습 니 다.select 를 통 해 접근 할 수도 없고 show tables 나 information.schema.tables 결과 에 나타 나 지 않 습 니 다.방문 을 시도 하면 다음 과 같은 오 류 를 보고 합 니 다.

mysql> select * from mysql.tables limit 10;
ERROR 3554 (HY000): Access to data dictionary table 'mysql.tables' is rejected.
단,debug 모드 에 서 는 숨겨 진 데이터 사전 표를 방문 할 수 있 습 니 다.설 치 를 다시 컴 파일 하고 debug 모드 로 프로 세 스 를 시작 합 니 다.다시 접근 을 시도 한 결 과 는 다음 과 같 습 니 다.

mysql> SET SESSION debug='+d,skip_dd_table_access_check';

mysql> SELECT name, schema_id, hidden, type FROM mysql.tables where schema_id=1 AND hidden='System';
+------------------------------+-----------+--------+------------+
| name             | schema_id | hidden | type    |
+------------------------------+-----------+--------+------------+
| catalogs           |     1 | System | BASE TABLE |
| character_sets        |     1 | System | BASE TABLE |
| check_constraints      |     1 | System | BASE TABLE |
| collations          |     1 | System | BASE TABLE |
| column_statistics      |     1 | System | BASE TABLE |
| column_type_elements     |     1 | System | BASE TABLE |
| columns           |     1 | System | BASE TABLE |
| dd_properties        |     1 | System | BASE TABLE |
| events            |     1 | System | BASE TABLE |
| foreign_key_column_usage   |     1 | System | BASE TABLE |
| foreign_keys         |     1 | System | BASE TABLE |
| index_column_usage      |     1 | System | BASE TABLE |
| index_partitions       |     1 | System | BASE TABLE |
| index_stats         |     1 | System | BASE TABLE |
| indexes           |     1 | System | BASE TABLE |
| innodb_ddl_log        |     1 | System | BASE TABLE |
| innodb_dynamic_metadata   |     1 | System | BASE TABLE |
| parameter_type_elements   |     1 | System | BASE TABLE |
| parameters          |     1 | System | BASE TABLE |
| resource_groups       |     1 | System | BASE TABLE |
| routines           |     1 | System | BASE TABLE |
| schemata           |     1 | System | BASE TABLE |
| st_spatial_reference_systems |     1 | System | BASE TABLE |
| table_partition_values    |     1 | System | BASE TABLE |
| table_partitions       |     1 | System | BASE TABLE |
| table_stats         |     1 | System | BASE TABLE |
| tables            |     1 | System | BASE TABLE |
| tablespace_files       |     1 | System | BASE TABLE |
| tablespaces         |     1 | System | BASE TABLE |
| triggers           |     1 | System | BASE TABLE |
| view_routine_usage      |     1 | System | BASE TABLE |
| view_table_usage       |     1 | System | BASE TABLE |
+------------------------------+-----------+--------+------------+
32 rows in set (0.01 sec)
기타 시스템 테이블
기타 시스템 테이블,show tables 또는 informationschema.tables 보기,모두 InnoDB 저장 엔진(geneallog、slow_log 예외,이 두 표 는 메타 데이터 정 보 를 기록 하지 않 고 로그 만 기록 합 니 다):

mysql> select table_schema,table_name,engine from information_schema.tables where table_schema='mysql';
+--------------+---------------------------+--------+
| TABLE_SCHEMA | TABLE_NAME        | ENGINE |
+--------------+---------------------------+--------+
| mysql    | columns_priv       | InnoDB |
| mysql    | component         | InnoDB |
| mysql    | db            | InnoDB |
| mysql    | default_roles       | InnoDB |
| mysql    | engine_cost        | InnoDB |
| mysql    | func           | InnoDB |
| mysql    | general_log        | CSV  |
| mysql    | global_grants       | InnoDB |
| mysql    | gtid_executed       | InnoDB |
| mysql    | help_category       | InnoDB |
| mysql    | help_keyword       | InnoDB |
| mysql    | help_relation       | InnoDB |
| mysql    | help_topic        | InnoDB |
| mysql    | innodb_index_stats    | InnoDB |
| mysql    | innodb_table_stats    | InnoDB |
| mysql    | password_history     | InnoDB |
| mysql    | plugin          | InnoDB |
| mysql    | procs_priv        | InnoDB |
| mysql    | proxies_priv       | InnoDB |
| mysql    | role_edges        | InnoDB |
| mysql    | server_cost        | InnoDB |
| mysql    | servers          | InnoDB |
| mysql    | slave_master_info     | InnoDB |
| mysql    | slave_relay_log_info   | InnoDB |
| mysql    | slave_worker_info     | InnoDB |
| mysql    | slow_log         | CSV  |
| mysql    | tables_priv        | InnoDB |
| mysql    | time_zone         | InnoDB |
| mysql    | time_zone_leap_second   | InnoDB |
| mysql    | time_zone_name      | InnoDB |
| mysql    | time_zone_transition   | InnoDB |
| mysql    | time_zone_transition_type | InnoDB |
| mysql    | user           | InnoDB |
+--------------+---------------------------+--------+
33 rows in set (0.00 sec)
데이터 사전 보기
방금 언급 했 듯 이 데이터 사전 표 는 debug 모드 에서 만 접근 할 수 있 습 니 다.그러면 생산 환경 에서 우 리 는 어떻게 메타 데이터 정 보 를 얻 어야 합 니까?정 답 은 informationschema 라 이브 러 리 의 데이터 사전 보기.Oracle 데이터베이스 의 디자인 이념 과 마찬가지 로 메타 데이터 정 보 를 기본 표(x$,$)에 저장 한 다음 보기(v$,dba /all_/user_)사용자 에 게 조회 하 는 방식 을 제공한다.MySQL 데이터베이스 도 마찬가지 입 니 다.my sql 라 이브 러 리 의 데이터 사전 표 에 메타 데이터 정 보 를 저장 하고 information 을 제공 합 니 다.schema 라 이브 러 리 보기 사용자 에 게 조회:

mysql> select table_schema,table_name,table_type,engine from information_schema.tables where table_schema='information_schema'; 
+--------------------+---------------------------------------+-------------+--------+
| TABLE_SCHEMA    | TABLE_NAME              | TABLE_TYPE | ENGINE |
+--------------------+---------------------------------------+-------------+--------+
| information_schema | ADMINISTRABLE_ROLE_AUTHORIZATIONS   | SYSTEM VIEW | NULL  |
| information_schema | APPLICABLE_ROLES           | SYSTEM VIEW | NULL  |
| information_schema | CHARACTER_SETS            | SYSTEM VIEW | NULL  |
| information_schema | CHECK_CONSTRAINTS           | SYSTEM VIEW | NULL  |
| information_schema | COLLATION_CHARACTER_SET_APPLICABILITY | SYSTEM VIEW | NULL  |
| information_schema | COLLATIONS              | SYSTEM VIEW | NULL  |
| information_schema | COLUMN_PRIVILEGES           | SYSTEM VIEW | NULL  |
| information_schema | COLUMN_STATISTICS           | SYSTEM VIEW | NULL  |
| information_schema | COLUMNS                | SYSTEM VIEW | NULL  |
| information_schema | ENABLED_ROLES             | SYSTEM VIEW | NULL  |
| information_schema | ENGINES                | SYSTEM VIEW | NULL  |
| information_schema | EVENTS                | SYSTEM VIEW | NULL  |
| information_schema | FILES                 | SYSTEM VIEW | NULL  |
| information_schema | INNODB_BUFFER_PAGE          | SYSTEM VIEW | NULL  |
| information_schema | INNODB_BUFFER_PAGE_LRU        | SYSTEM VIEW | NULL  |
| information_schema | INNODB_BUFFER_POOL_STATS       | SYSTEM VIEW | NULL  |
| information_schema | INNODB_CACHED_INDEXES         | SYSTEM VIEW | NULL  |
| information_schema | INNODB_CMP              | SYSTEM VIEW | NULL  |
| information_schema | INNODB_CMP_PER_INDEX         | SYSTEM VIEW | NULL  |
| information_schema | INNODB_CMP_PER_INDEX_RESET      | SYSTEM VIEW | NULL  |
| information_schema | INNODB_CMP_RESET           | SYSTEM VIEW | NULL  |
| information_schema | INNODB_CMPMEM             | SYSTEM VIEW | NULL  |
| information_schema | INNODB_CMPMEM_RESET          | SYSTEM VIEW | NULL  |
| information_schema | INNODB_COLUMNS            | SYSTEM VIEW | NULL  |
| information_schema | INNODB_DATAFILES           | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FIELDS             | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FOREIGN            | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FOREIGN_COLS          | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FT_BEING_DELETED        | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FT_CONFIG           | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FT_DEFAULT_STOPWORD      | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FT_DELETED           | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FT_INDEX_CACHE         | SYSTEM VIEW | NULL  |
| information_schema | INNODB_FT_INDEX_TABLE         | SYSTEM VIEW | NULL  |
| information_schema | INNODB_INDEXES            | SYSTEM VIEW | NULL  |
| information_schema | INNODB_METRICS            | SYSTEM VIEW | NULL  |
| information_schema | INNODB_SESSION_TEMP_TABLESPACES    | SYSTEM VIEW | NULL  |
| information_schema | INNODB_TABLES             | SYSTEM VIEW | NULL  |
| information_schema | INNODB_TABLESPACES          | SYSTEM VIEW | NULL  |
| information_schema | INNODB_TABLESPACES_BRIEF       | SYSTEM VIEW | NULL  |
| information_schema | INNODB_TABLESTATS           | SYSTEM VIEW | NULL  |
| information_schema | INNODB_TEMP_TABLE_INFO        | SYSTEM VIEW | NULL  |
| information_schema | INNODB_TRX              | SYSTEM VIEW | NULL  |
| information_schema | INNODB_VIRTUAL            | SYSTEM VIEW | NULL  |
| information_schema | KEY_COLUMN_USAGE           | SYSTEM VIEW | NULL  |
| information_schema | KEYWORDS               | SYSTEM VIEW | NULL  |
| information_schema | OPTIMIZER_TRACE            | SYSTEM VIEW | NULL  |
| information_schema | PARAMETERS              | SYSTEM VIEW | NULL  |
| information_schema | PARTITIONS              | SYSTEM VIEW | NULL  |
| information_schema | PLUGINS                | SYSTEM VIEW | NULL  |
| information_schema | PROCESSLIST              | SYSTEM VIEW | NULL  |
| information_schema | PROFILING               | SYSTEM VIEW | NULL  |
| information_schema | REFERENTIAL_CONSTRAINTS        | SYSTEM VIEW | NULL  |
| information_schema | RESOURCE_GROUPS            | SYSTEM VIEW | NULL  |
| information_schema | ROLE_COLUMN_GRANTS          | SYSTEM VIEW | NULL  |
| information_schema | ROLE_ROUTINE_GRANTS          | SYSTEM VIEW | NULL  |
| information_schema | ROLE_TABLE_GRANTS           | SYSTEM VIEW | NULL  |
| information_schema | ROUTINES               | SYSTEM VIEW | NULL  |
| information_schema | SCHEMA_PRIVILEGES           | SYSTEM VIEW | NULL  |
| information_schema | SCHEMATA               | SYSTEM VIEW | NULL  |
| information_schema | ST_GEOMETRY_COLUMNS          | SYSTEM VIEW | NULL  |
| information_schema | ST_SPATIAL_REFERENCE_SYSTEMS     | SYSTEM VIEW | NULL  |
| information_schema | ST_UNITS_OF_MEASURE          | SYSTEM VIEW | NULL  |
| information_schema | STATISTICS              | SYSTEM VIEW | NULL  |
| information_schema | TABLE_CONSTRAINTS           | SYSTEM VIEW | NULL  |
| information_schema | TABLE_PRIVILEGES           | SYSTEM VIEW | NULL  |
| information_schema | TABLES                | SYSTEM VIEW | NULL  |
| information_schema | TABLESPACES              | SYSTEM VIEW | NULL  |
| information_schema | TRIGGERS               | SYSTEM VIEW | NULL  |
| information_schema | USER_PRIVILEGES            | SYSTEM VIEW | NULL  |
| information_schema | VIEW_ROUTINE_USAGE          | SYSTEM VIEW | NULL  |
| information_schema | VIEW_TABLE_USAGE           | SYSTEM VIEW | NULL  |
| information_schema | VIEWS                 | SYSTEM VIEW | NULL  |
+--------------------+---------------------------------------+-------------+--------+
73 rows in set (0.00 sec)

mysql> show create table information_schema.tables\G
*************************** 1. row ***************************
        View: TABLES
     Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`mysql.infoschema`@`localhost` SQL SECURITY DEFINER VIEW `information_schema`.`TABLES` AS select (`cat`.`name` collate utf8_tolower_ci) AS `TABLE_CATALOG`,(`sch`.`name` collate utf8_tolower_ci) AS `TABLE_SCHEMA`,(`tbl`.`name` collate utf8_tolower_ci) AS `TABLE_NAME`,`tbl`.`type` AS `TABLE_TYPE`,if((`tbl`.`type` = 'BASE TABLE'),`tbl`.`engine`,NULL) AS `ENGINE`,if((`tbl`.`type` = 'VIEW'),NULL,10) AS `VERSION`,`tbl`.`row_format` AS `ROW_FORMAT`,if((`tbl`.`type` = 'VIEW'),NULL,internal_table_rows(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(`stat`.`table_rows`,0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `TABLE_ROWS`,if((`tbl`.`type` = 'VIEW'),NULL,internal_avg_row_length(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(`stat`.`avg_row_length`,0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `AVG_ROW_LENGTH`,if((`tbl`.`type` = 'VIEW'),NULL,internal_data_length(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(`stat`.`data_length`,0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `DATA_LENGTH`,if((`tbl`.`type` = 'VIEW'),NULL,internal_max_data_length(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(`stat`.`max_data_length`,0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `MAX_DATA_LENGTH`,if((`tbl`.`type` = 'VIEW'),NULL,internal_index_length(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(`stat`.`index_length`,0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `INDEX_LENGTH`,if((`tbl`.`type` = 'VIEW'),NULL,internal_data_free(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(`stat`.`data_free`,0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `DATA_FREE`,if((`tbl`.`type` = 'VIEW'),NULL,internal_auto_increment(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(`stat`.`auto_increment`,0),coalesce(cast(`stat`.`cached_time` as unsigned),0),`tbl`.`se_private_data`)) AS `AUTO_INCREMENT`,`tbl`.`created` AS `CREATE_TIME`,if((`tbl`.`type` = 'VIEW'),NULL,internal_update_time(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(cast(`stat`.`update_time` as unsigned),0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `UPDATE_TIME`,if((`tbl`.`type` = 'VIEW'),NULL,internal_check_time(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(cast(`stat`.`check_time` as unsigned),0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `CHECK_TIME`,`col`.`name` AS `TABLE_COLLATION`,if((`tbl`.`type` = 'VIEW'),NULL,internal_checksum(`sch`.`name`,`tbl`.`name`,if((`tbl`.`partition_type` is null),`tbl`.`engine`,''),`tbl`.`se_private_id`,(`tbl`.`hidden` <> 'Visible'),`ts`.`se_private_data`,coalesce(`stat`.`checksum`,0),coalesce(cast(`stat`.`cached_time` as unsigned),0))) AS `CHECKSUM`,if((`tbl`.`type` = 'VIEW'),NULL,get_dd_create_options(`tbl`.`options`,if((ifnull(`tbl`.`partition_expression`,'NOT_PART_TBL') = 'NOT_PART_TBL'),0,1),if((`sch`.`default_encryption` = 'YES'),1,0))) AS `CREATE_OPTIONS`,internal_get_comment_or_error(`sch`.`name`,`tbl`.`name`,`tbl`.`type`,`tbl`.`options`,`tbl`.`comment`) AS `TABLE_COMMENT` from (((((`mysql`.`tables` `tbl` join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) left join `mysql`.`collations` `col` on((`tbl`.`collation_id` = `col`.`id`))) left join `mysql`.`tablespaces` `ts` on((`tbl`.`tablespace_id` = `ts`.`id`))) left join `mysql`.`table_stats` `stat` on(((`tbl`.`name` = `stat`.`table_name`) and (`sch`.`name` = `stat`.`schema_name`)))) where ((0 <> can_access_table(`sch`.`name`,`tbl`.`name`)) and (0 <> is_visible_dd_object(`tbl`.`hidden`)))
character_set_client: utf8
collation_connection: utf8_general_ci
1 row in set (0.00 sec)
데이터 사전 캐 시
MySQL 8.0 은 디스크 IO 를 줄 이 고 접근 효율 을 높이 기 위해 데이터 사전 캐 시 를 도입 했다.데이터 사전 캐 시 는 LRU 알고리즘 을 통 해 메모리 관 리 를 하 는 전역 공유 영역 입 니 다.구체 적 으로 는 다음 과 같 습 니 다.

tablespace definition cache partition:           ;       tablespace_definition_cache  。
schema definition cache partition:          ;       schema_definition_cache  。
table definition cache partition:         ;       max_connections  。
stored program definition cache partition:            ;       stored_program_definition_cache  。
character set definition cache partition:           ;     256 。
collation definition cache partition:            ;     256 。
원자 DDL
우선 원자 성 이 무엇 인지 알 아 보 자.원자 성 이란 하나의 업무 수행 이 모두 성공 하거나 모두 실패 하 는 것 을 말한다.
MySQL 8.0 이전 에는 원자 DDL 이 지원 되 지 않 아 서비스 프로 세 스 가 비정상적 으로 종료 되 거나 서버 가 비정상적 으로 지연 되 는 경우 데이터 사전,저장 엔진 구조,바 이 너 리 로그 간 의 불일치 가 발생 할 수 있 습 니 다.
MySQL 8.0 에 서 는 데이터 사전 이 모두 이 노 DB 메모리 엔진 시트 로 개 조 됐 고 원자 DDL 도 도입 됐다.원자 DDL 은 데이터 사전 업데이트,저장 엔진 작업,바 이 너 리 로 그 를 같은 사무 에 기록 하여 실행 하거나 모두 성공 적 으로 제출 하거나 모두 실패 하고 스크롤 백 합 니 다.
이어서 우 리 는 먼저 하나의 예 를 통 해 원자 DDL 을 알 아 보 는 것 이 좋 겠 다.이 예 에서 DROP TABLE t1,t2 는 같은 업무 에 속 합 니 다.5.7 버 전에 서 하나의 사무 부분,성공 부분 이 실 패 했 는데 그것 이 바로 DROP TABLE t1 성공,DROP TABLE t2 실패 이다.그러나 8.0 버 전에 서 DROP TABLE t2 가 실 패 했 기 때문에 전체 업무 가 실 패 했 습 니 다.이 예 는 원자 성과 비 원자 성의 차 이 를 잘 나 타 냈 다.

5.7  :
mysql> CREATE TABLE t1 (c1 INT);
mysql> DROP TABLE t1, t2;
ERROR 1051 (42S02): Unknown table 'test.t2'
mysql> SHOW TABLES;
Empty set (0.00 sec)

8.0  :
mysql> CREATE TABLE t1 (c1 INT);
mysql> DROP TABLE t1, t2;
ERROR 1051 (42S02): Unknown table 'test.t2'
mysql> SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| t1       |
+----------------+
원자 DDL 에 대해 초보적인 이 해 를 한 후에 구체 적 인 과정 을 소개 한다.
(1)prepare:필요 한 대상 을 만 들 고 ddl 로 그 를 my sql.innodb 에 기록 합 니 다.ddl_log;ddl 로 그 는 스크롤 백 과 스크롤 백 ddl 작업 을 기록 합 니 다.
(2)perform:ddl 작업 을 수행 합 니 다.
(3)commt:데이터 사전 을 업데이트 하고 제출 합 니 다.
(4)post-ddl:ddl 로 그 를 재생 하고 삭제 합 니 다.실례 가 비정상적 으로 지연 되 었 을 때 만 ddl 로 그 는 mysql.innodb 에 계속 저 장 됩 니 다ddl_log;인 스 턴 스 를 다시 시작 한 후 인 스 턴 스 복구 단 계 를 진행 하면 ddl 로 그 는 재생 되 고 삭 제 됩 니 다.3 단계-데이터 사전 업데이트 가 성공 적 으로 제출 되 었 고 redo log 와 binlog 를 기록 하면 dl 작업 이 성공 합 니 다.그렇지 않 으 면 ddl 작업 이 실 패 했 고 ddl 로그 에 따라 스크롤 백 합 니 다.
마지막 으로 다시 한 번 소개 하 겠 습 니 다.DDL 로 그 를 어떻게 봅 니까?
그 중 하 나 는 debug 단계 에서 방문 표 my sql.innodb 입 니 다.ddl_로그 에서 보기(추천 하지 않 음)

CREATE TABLE mysql.innodb_ddl_log (
 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
 thread_id BIGINT UNSIGNED NOT NULL,
 type INT UNSIGNED NOT NULL,
 space_id INT UNSIGNED,
 page_no INT UNSIGNED,
 index_id BIGINT UNSIGNED,
 table_id BIGINT UNSIGNED,
 old_file_path VARCHAR(512) COLLATE UTF8_BIN,
 new_file_path VARCHAR(512) COLLATE UTF8_BIN,
 KEY(thread_id)
);
또 다른 방법 은 DDL 로 그 를 error log 에 인쇄 하여 볼 수 있 습 니 다(추천)

mysql> set global innodb_print_ddl_logs=on;
Query OK, 0 rows affected (0.00 sec)

mysql> set global LOG_ERROR_VERBOSITY=3;
Query OK, 0 rows affected (0.00 sec)

mysql> create table test(id int);
Query OK, 0 rows affected (0.04 sec)

$ tail -100f mysql-error.log
2020-08-17T19:55:09.804345+08:00 73 [Note] [MY-012473] [InnoDB] DDL log insert : [DDL record: DELETE SPACE, id=57, thread_id=73, space_id=12, old_file_path=./test/test.ibd]
2020-08-17T19:55:09.804396+08:00 73 [Note] [MY-012478] [InnoDB] DDL log delete : 57
2020-08-17T19:55:09.816850+08:00 73 [Note] [MY-012477] [InnoDB] DDL log insert : [DDL record: REMOVE CACHE, id=58, thread_id=73, table_id=1069, new_file_path=test/test]
2020-08-17T19:55:09.816887+08:00 73 [Note] [MY-012478] [InnoDB] DDL log delete : 58
2020-08-17T19:55:09.820623+08:00 73 [Note] [MY-012472] [InnoDB] DDL log insert : [DDL record: FREE, id=59, thread_id=73, space_id=12, index_id=160, page_no=4]
2020-08-17T19:55:09.820673+08:00 73 [Note] [MY-012478] [InnoDB] DDL log delete : 59
2020-08-17T19:55:09.837695+08:00 73 [Note] [MY-012485] [InnoDB] DDL log post ddl : begin for thread id : 73
2020-08-17T19:55:09.837721+08:00 73 [Note] [MY-012486] [InnoDB] DDL log post ddl : end for thread id : 73
총결산
MySQL 8.0 은 데이터 사전 의 개선 에 많은 장점 을 가 져 왔 습 니 다.메타 데이터 통일 관리,데이터 사전 캐 시,information 을 포함 합 니 다.schema 성능 향상,원자 DDL 등.
이상 은 MySQL 8.0 의 새로운 특성 을 분석 하 는 것 입 니 다.사무 적 데이터 사전 과 원자 DDL 의 상세 한 내용 입 니 다.MySQL 8.0 의 새로운 특성 에 관 한 자 료 는 우리 의 다른 관련 글 을 주목 하 십시오!

좋은 웹페이지 즐겨찾기