In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Introduction
When InnoDB starts, if you create a new database, you need to initialize the library and create relevant information about dictionary management. The function innobase_start_or_create_for_mysql calls dict_create to complete this function. That is, to create a data dictionary, because the number of InnoDB system tables is fixed, so when initializing the library, you only need to create the B + tree of these tables and store the root page number of the B + tree to a fixed location. For B+ trees, as long as you find the root page, you can retrieve data from the root page. The relevant system tables (that is, the four system tables mentioned in the previous section) are within InnoDB and are not exposed to users. Four system tables are built by fixed hard coding. The specific principle and process are as follows.
2. Principle flow of data dictionary creation and loading.
3. Description
1) the innobase_start_or_create_for_mysql function calls the dict_create () function to create and load the data dictionary.
2) dict_hdr_create completes the initialization of page 7 of the system tablespace dict header and creates two indexes of SYS_TABLES, one index of SYS_COLUMNS, one index of SYS_INDEXES and one index of SYS_FIELDS. The function of creating index is btr_create.
3) after creating the Btree index, load the four system tables that are resident in memory through the dict_boot function. See the ② section of the flow chart for details.
4) after loading, hang the four system tables in a global dictionary:
Dict0dict.h::
/ * Dictionary system struct * / struct dict_sys_t {ib_mutex_t mutex; / *! < mutex protecting the data dictionary; protects also the disk-based dictionary system tables This mutex serializes CREATE TABLE and DROP TABLE, as well as reading the dictionary data for a table from system tables * / row_id_t row_id; / *! < the next row id to assign NOTE that at a checkpoint this must be written to the dict system header and flushed to a file; in recovery this must be derived from the log records * / hash_table_t* table_hash / *! < hash table of the tables, based on name * / hash_table_t* table_id_hash; / *! < hash table of the tables, based on id * / ulint size / *! < varying space in bytes occupied by the data dictionary table and index objects * / dict_table_t* sys_tables; / *! < SYS_TABLES table * / dict_table_t* sys_columns; / *! < SYS_COLUMNS table * / dict_table_t* sys_indexes / *! < SYS_INDEXES table * / dict_table_t* sys_fields; / *! < SYS_FIELDS table * / / * = = * / UT_LIST_BASE_NODE_T (dict_table_t) table_LRU / *! < List of tables that can be evicted from the cache * / UT_LIST_BASE_NODE_T (dict_table_t) table_non_LRU; / *! < List of tables that can't be evicted from the cache * /}
The four structures of sys_tables, sys_columns, sys_indexes and sys_fields in the structure store the four system tables mentioned above.
The hash table and linked list in the structure are used to store the cache of all tables in InnoDB, including system table and user table. The table_ hash hash table is cached by name, and table_id_hash is used to manage the table object cache by hash,LRU linked list by table ID.
5) for the loading process of common user table, please see the ③ and ④ sections of the flow chart.
When a user accesses a user table, he or she first needs to look up the SHARE object of the table from the table object cache, and if it finds one, it will use it directly from its instantiated list of table objects; if it is not found, it needs to reopen the table and find the dictionary information for the table. The process of ③.
The dictionary that specifically loads a table is the ④ process, the work of dict_load_table.
A) first you need to find the SYS_TABLES table, and also find the cache first. If the cache cannot be found, then load it from the system table: dict_table_get_low
B) build a query key value after it is found, query it from the name primary key index of SYS_TABLES, and return if it is found or the record has been deleted, otherwise parse the found record. Then the memory object table of the table is created based on this information.
C) the principle of loading column operation is basically the same as loading table, corresponding to the SYS_COLUMNS of the system table, the clustered index is (TABLE_ID,POS). When looking up, if the TABLE_ID is the same, the POS is sorted from small to large, so when constructing the key values of all columns, you only need to query through TABLE_ID and take out all the column information in order to construct a memory object.
D) A similar process for loading index information
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.