information_schema system libraries - Introduction and constituent objects

Series of articles making reference to "MySQL Performance Optimization Pyramid law", deleted the book and repeated explanation is too complex some explanation, please refer to the full version of the original book.

information_schema but also simpler than some of the sys system libraries, no additional configuration, which only need to know what table, what information to be able to query.

 

First, what is information_schema

1 Introduction

information_schema provides access to database metadata information, statistics and information about the MySQL Server. It is similar to MySQL data dictionary or the system catalog.

  • Each instance has a MySQL separate information_schema, for all the basic information database storing the other example MySQL

  • Library tables in memory (non-persistent tables), so there is no corresponding file in the disk associated data directory, data will be lost after restart

  • Library tables are read-only, can not be modified, nor can you set the trigger for these tables.

  • TABLE statements can replace some of the show (eg SHOW DATABASES, SHOW TABLES, etc.) in the query information_schema

 

2. Access information_schema needed

  • All users have permission to access the table under information_schema , but by default only access the Server layer part of the data dictionary table

  • To access other data dictionary tables and InnoDB layer Server layer of data dictionary table, the user needs to have the process privilege (note not select permissions, authorized under the table select information_schema being given insufficient privileges).

  • Required permissions also apply to the SHOW statement. Either use the query, an object must have permission to see the relevant data.

 

3. Brief History of changes

  • Table 5.6 version of a total of 59, of which 10 MyISAM engine temporary table (data dictionary tables), 49 Memory engine temporary table (statistics and some temporary information).
  • Table 5.7 version of 61, wherein the temporary storage engine 10 InnoDB table (data dictionary table), the temporary table 51 Memory engine.
  • Version 8.0 to migrate data dictionary table and part of the original memory engine mysql temporary table to the library, and these tables are hidden and can not be accessed directly in the mysql database needs to be accessed by different watches at information_schema. In the statistics table reserved for the Memory and still information_schema engine.

 

Two, information_schema constituent objects

In accordance with the purpose and the similarity of these tables, we put under the table information_schema made the following classification.

1. Server layer statistics dictionary table

COLUMNS:

  • Provided in the table columns (fields) information

  • The table is temporary InnoDB storage engine

KEY_COLUMN_USAGE:

  • What presence query constraint index column, contains the primary key, the unique index information constraints, foreign keys. Information table with information TABLE_CONSTRAINTS records in the table is somewhat similar, but the table does not record TABLE_CONSTRAINTS constraint referenced database table column information.

  • The table is a temporary table Memory engine

REFERENTIAL_CONSTRAINTS:

  • Provide access to some information about foreign key constraints

  • The table is a temporary table Memory engine

STATISTICS:

  • Provide access to some statistical information about the index, the index corresponds to a row of record

  • The table is a temporary table Memory engine

TABLE_CONSTRAINTS:

  • Providing a lookup table constraints related information

  • The table is a temporary table Memory engine

FILES:

  • MySQL query to provide relevant information data table space file that contains InnoDB and NDB storage engine related data file information

  • The table Memory table storage engine

ENGINES:

  • Provide access to MySQL Server supports engine-related information

  • The table is a temporary table Memory engine

TABLESPACES:

  • Provide relevant information on active table space (mainly records the NDB storage engine table space information)

  • The table does not provide information about table space in the InnoDB storage engine. InnoDB table space metadata information, please consult INNODB_SYS_TABLESPACES and INNODB_SYS_DATAFILES table. 5.7.8 From the start, INFORMATION_SCHEMA.FILES table also provides metadata information InnoDB table space

  • The table is a temporary table Memory engine.

SCHEMATA:

  • MySQL database query to provide a list of information in a schema is a database

  • The table is a temporary table Memory engine

 

2. Server layer object dictionary table

VIEWS:

  • Provide relevant information view query the database, query the account of the table needs to have permission to show view

  • The table is a temporary table InnoDB engine

TRIGGERS:

  • Provide relevant information on the database under a flip-flop, flip-flop to query a table, query the account must have permission to trigger

  • The table is a temporary table InnoDB engine

TABLES:

  • Provide basic information related to the table in the database query

  • The table is a temporary table Memory engine

ROUTINES:

  • Provided the information about the storage process and storage functions (not including user-defined function UDF), the table correspond to the table information mysql.proc

  • The table is a temporary table InnoDB engine

PARTITIONS:

  • Provide access to information about the partition table

  • The table is a temporary table InnoDB engine

EVENTS:

  • Provide access to information related to the event scheduled task

  • The table is a temporary table InnoDB engine

PARAMETERS:

  • Stored procedures and functions provide the parameter information, and the information about the return value of a function of storage. SUMMARY param_list column parameters recorded information table similar mysql.proc

  • The table is a temporary table InnoDB engine

 

3. Server layer mixed messages dictionary table

GLOBAL_STATUS、GLOBAL_VARIABLES、SESSION_STATUS、SESSION_VARIABLES:

  • Provide access to a global, session-level state variable and variable information system, these tables as temporary tables Memory engine

OPTIMIZER_TRACE:

  • Optimizer function provides tracking information generated.

  • Tracking feature turned off by default, use optimizer_trace system variable tracing is enabled. If enabled, each session can only track their own statements executed, and only last a track record of SQL statements

  • The table is a temporary table InnoDB engine

PLUGINS:

  • What plug-ins provide information about the queries in MySQL Server support

  • The table is a temporary table InnoDB engine

PROCESSLIST:

  • Some states provide access to information about the process thread running

  • The table is a temporary table InnoDB engine

PROFILING:

  • Provide information about the query performance analysis statement. Information corresponding to the content recorded SHOW PROFILES and SHOW PROFILE statements generated. The table needs in a session variable profiling = statement will be recorded performance analysis information 1:00, or do not record.

  • Note: Starting with MySQL 5.7.2, this table is no longer recommended, deleted in future versions of MySQL. Instead of switching to Performance Schema

  • The table is a temporary table Memory engine

CHARACTER_SETS:

  • Provide access to MySQL Server supports the available character sets which

  • The table is a temporary table Memory engine

COLLATIONS:

  • Provide access to MySQL Server support available collation What

  • The table is a temporary table Memory engine

COLLATION_CHARACTER_SET_APPLICABILITY:

  • MySQL Server provides a query in which character set is suitable for what collation. The first two field values ​​corresponding to the results of the query result set obtained from SHOW COLLATION concentrated. The table currently and have not found much effect,

  • The table is a temporary table Memory engine

COLUMN_PRIVILEGES:

  • Provide access to the right information about the columns, the table of contents from mysql.column_priv column privileges table (need for authorization after a column of the table will have separate content)

  • The table is a temporary table Memory engine

SCHEMA_PRIVILEGES:

  • Provide access to the right information about the level of the library, library-level permissions for each type of recording one line of information, information in this table from the table mysql.db

  • The table is a temporary table Memory engine

TABLE_PRIVILEGES:

  • Provide access to information on the table level permissions, the contents of the table from mysql.tables_priv

  • The table is a temporary table Memory engine

USER_PRIVILEGES:

  • Provide information query the global authority, the information in this table from the table mysql.user

  • The table is a temporary table Memory engine

 

Layer system dictionary table 4. InnoDB

INNODB_SYS_DATAFILES:

  • Providing a query InnoDB file-per-table and a regular table space data file path information , information equivalent to the InnoDB internal data dictionary table SYS_DATAFILES

  • The information table contains all InnoDB tablespace types of metadata , including separate tablespaces, regular table space, the system table space, temporary table space and undo tablespace

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege.

INNODB_SYS_VIRTUAL:

  • Providing a query about InnoDB dummy information sequence and generate metadata associated column, equivalent to the internal data dictionary information InnoDB SYS_VIRTUAL table. Line information INNODB_SYS_VIRTUAL table shows that the virtual information is generated for each column in the associated column column.

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_SYS_INDEXES:

  • Provide inquiries about InnoDB index metadata information , equivalent to the information InnoDB internal data dictionary table SYS_INDEXES

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_SYS_TABLES:

  • Provide inquiries about InnoDB table metadata , information equivalent to the InnoDB data dictionary internal SYS_TABLES table.

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_SYS_FIELDS:

  • Provide access to relevant metadata information InnoDB index column , equivalent to the InnoDB data dictionary information table inside SYS_FIELDS

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_SYS_TABLESPACES:

  • Provide inquiries about the metadata information InnoDB table space and independence ordinary table space (also contains the full-text index table space), equivalent to the information InnoDB internal data dictionary table SYS_TABLESPACES

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_SYS_FOREIGN_COLS:

  • Providing a query about InnoDB foreign key column status information , information equivalent to the InnoDB internal data dictionary table SYS_FOREIGN_COLS

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_SYS_COLUMNS:

  • Provide access to relevant metadata information InnoDB table columns , equivalent to the InnoDB data dictionary information table inside SYS_COLUMNS

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_SYS_FOREIGN:

  • Providing query about the metadata information InnoDB foreign keys , information equivalent to the InnoDB internal data dictionary table SYS_FOREIGN

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_SYS_TABLESTATS:

  • Provide inquiries about a lower level of InnoDB table view status information . The optimizer uses these statistics to calculate the data and determine when a query InnoDB table which index to use. InnoDB without a corresponding internal system tables.

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

 

5. InnoDB layer locks, transactions, statistics dictionary table

INNODB_LOCKS:

  • Innodb engine to query the transaction and lock information when a blockage occurs

  • The table memory engine temporary table, the table needs to have access to have the process privilege

INNODB_TRX:

  • Provide access to information about each transaction currently executed in the InnoDB engine (not including read-only transactions) of , including whether the transaction is waiting for a lock, the start time of the transaction, executing SQL and so on.

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_BUFFER_PAGE_LRU:

  • Provide access to the buffer pool page information , save the page about the innodb buffer pool in the LRU list and determine how to enter in the buffer pool is not enough which pages need evicted from the buffer pool

  • The table is a temporary table Memory engine

INNODB_LOCK_WAITS:

  • Providing query on lock each InnoDB transaction is blocked waiting for records , including locks and obstruction blocking the requested transaction is granted

  • The table memory engine tables, users need to have access to the list process rights

INNODB_TEMP_TABLE_INFO:

  • Provide access to relevant examples in InnoDB InnoDB temporary tables currently active user created information , do not provide information queries a temporary table inside InnoDB query optimizer uses.

  • INNODB_TEMP_TABLE_INFO table is created when the first query.

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_BUFFER_PAGE:

  • Providing a query regarding information in the page buffer pool related

  • Query the table requires the user to have the PROCESS privilege, the table is a temporary table Memory engine

INNODB_METRICS:

  • Provide more detailed performance information, it is a supplement to the PERFORMANCE_SCHEMA . You can check the overall health innodb, and diagnose performance bottlenecks, resource shortages and other problems and applications.

  • The table is a temporary memory engine tables, queries the table user needs to have the process privilege

INNODB_BUFFER_POOL_STATS:

  • Providing query status information in a number of buffer pool Innodb , the information recorded in the information table SHOW ENGINE INNODB STATUS output similar to the same, further, a number of state variables InnoDB buffer pool also provides the same value portion

  • View the table needs to have the process privilege, the table is a temporary table Memory engine

 

6. InnoDB layer full-text index dictionary table

INNODB_FT_CONFIG:

  • Provide inquiries about InnoDB table metadata and associated information FULLTEXT index. Prior to query this table, we need to set innodb_ft_aux_table = 'db_name / tb_name', db_name / tb_name table name and library that contains full-text index.

  • Query the table account requires PROCESS privilege, the table is a temporary table Memory engine

INNODB_FT_BEING_DELETED:

  • As a snapshot of the data INNODB_FT_DELETED table stored in the table is only used during maintenance operations in the OPTIMIZE TABLE statement. When you run the OPTIMIZE TABLE statement, data INNODB_FT_BEING_DELETED will first clear the table, save a snapshot of the data INNODB_FT_DELETED table to INNODB_FT_BEING_DELETED table, and delete DOC_ID from INNODB_FT_DELETED table. Since the content INNODB_FT_BEING_DELETED table usually short life cycle, the data in this table is useful for debugging or monitoring is not large.

  • The default table does not record data, you need to set system configuration parameters innodb_ft_aux_table = string (string representation db_name.tb_name string), and full-text index is created, set the stop words and so on.

  • Query the table account requires PROCESS privilege, the table is a temporary table Memory engine

INNODB_FT_DELETED:

  • Provide access line information deleted from InnoDB FULLTEXT index table. It exists to avoid costly index reorganization operation during InnoDB FULLTEXT indexes DML operations, information full-text index of the new deletion of the word will be stored in the table alone, when performing a text search which filter out the search results, the information in table is empty when executing OPTIMIZE tABLE statement.

  • Information in this table is not recorded by default, requires innodb_ft_aux_table options (which default is an empty string) specifying information which needs innodb Engine Table records, for example: test / test.

  • Query the table account requires PROCESS privilege, the table is a temporary table Memory engine

INNODB_FT_DEFAULT_STOPWORD:

  • The table to the default full-text index stop list, provide access to a list of stop words value. Enable stop-list parameters need to open innodb_ft_enable_stopword = ON, the default parameter is ON, enable the function after stop words, if innodb_ft_user_stopword_table option (to take effect for the specified engine innodb table full-text index) customized the disabled thesaurus table name value, then disable the function using the word stop list innodb_ft_user_stopword_table option to specify if innodb_ft_user_stopword_table option is not specified, but innodb_ft_server_stopword_table option (to take effect for all engine innodb table full-text index) customized the disabled thesaurus table name value, stop-list feature uses the same stop words innodb_ft_server_stopword_table option to specify if innodb_ft_server_stopword_table option is also not specified, the default stop list, namely INNODB_FT_DEFAULT_STOPWORD table.

  • Query the table needs to have an account PROCESS privilege, the table is a temporary table Memory engine

INNODB_FT_INDEX_TABLE:

  • Inquire About innodb table provides full-text indexing for word the text information reverse lookup inverted index.

  • Query the table account requires PROCESS privilege, the table is a temporary table Memory engine

INNODB_FT_INDEX_CACHE:

  • Provide access to full-text indexing tag information innodb storage engine FULLTEXT index table contains the newly inserted row. It exists in order to avoid costly index reorganization during DML operations, information on the newly inserted full-text index word is stored separately in the table, when there until OPTIMIZE TABLE statement on a table, or server, or when information stored in the cache size exceeds the size will perform cleanup innodb_ft_cache_size or innodb_ft_total_cache_size system configuration parameters specified. The default does not record data, you need to use innodb_ft_aux_table system configuration parameter specifies the full-text index of the table data which newly inserted row needs to be recorded.

  • Query the table account requires PROCESS privilege, the table is a temporary table Memory engine

 

7. InnoDB layer associated compression dictionary table

INNODB_CMP和INNODB_CMP_RESET:

  • Status information related to the compressed page table InnoDB operation , reference data in the table in the database to measure the effectiveness of InnoDb table compression.

  • User query table must have PROCESS privilege, the table is a temporary table Memory engine

INNODB_CMP_PER_INDEX和INNODB_CMP_PER_INDEX_RESET:

  • InnoDB compression table data and index information relating to the operating state of the database, for each combination of tables, indexes, using different statistics, to provide reference data for evaluating compression performance and utility of a particular table.

  • For InnoDB compression table, the data table will all secondary index are compressed. At this time, data in the table is considered clustered index contains all the data columns.

  • Note: Due to collect a separate index for each measure will lead to a significant reduction in performance, and therefore does not collect INNODB_CMP_PER_INDEX INNODB_CMP_PER_INDEX_RESET table statistics by default. If deemed necessary, to enable the system configuration parameters innodb_cmp_per_index_enabled (the configuration parameter is dynamic variables, default is OFF).

  • Query the table account requires PROCESS privilege, the table is a temporary table Memory engine

INNODB_CMPMEM和INNODB_CMPMEM_RESET:

  • These two tables are recorded in the status information on the compressed page buffer pool InnoDB, InnoDB measurement database table compression effectiveness provided as a reference

  • Query the table account requires PROCESS privilege, the table is a temporary table Memory engine

 

More reference https://dev.mysql.com/doc/refman/5.7/en/information-schema.html

Published 295 original articles · won praise 35 · views 80000 +

Guess you like

Origin blog.csdn.net/Hehuyi_In/article/details/105325299