*****************************
关于索引的创建
*****************************
create table z (
a int not null,
b int null,
c int not null,
d int not null,
unique key (b) ,
unique key (d) ,
unique key (c));
insert into z select 1,2,3,4;
insert into z select 5,6,7,8;
insert into z select 9,10,11,12;
select a,b,c,d_rowid from z;
mysql> select a,b,c,d,_rowid from z;
+---+------+----+----+--------+
| a | b | c | d | _rowid |
+---+------+----+----+--------+
| 1 | 2 | 3 | 4 | 4 |
| 5 | 6 | 7 | 8 | 8 |
| 9 | 10 | 11 | 12 | 12 |
+---+------+----+----+--------+
3 rows in set (0.01 sec)
*****************************
关于表空间
*****************************
show variables like '%innodb_file_per_table%';
mysql> show variables like '%innodb_file_per_table%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_file_per_table | ON |
+-----------------------+-------+
1 row in set (0.04 sec)
数据即索引,索引即数据
*****************************
关于数据文件位置
*****************************
mysql> system ls -lh /var/lib/mysql/*
-rw-r-----. 1 mysql mysql 56 Apr 27 14:10 /var/lib/mysql/auto.cnf
-rw-------. 1 mysql mysql 1.7K Apr 27 14:10 /var/lib/mysql/ca-key.pem
-rw-r--r--. 1 mysql mysql 1.1K Apr 27 14:10 /var/lib/mysql/ca.pem
-rw-r--r--. 1 mysql mysql 1.1K Apr 27 14:10 /var/lib/mysql/client-cert.pem
-rw-------. 1 mysql mysql 1.7K Apr 27 14:10 /var/lib/mysql/client-key.pem
-rw-r-----. 1 mysql mysql 177 Apr 30 15:40 /var/lib/mysql/dayu.000001
-rw-r-----. 1 mysql mysql 196 Apr 30 16:09 /var/lib/mysql/dayu.000002
-rw-r-----. 1 mysql mysql 196 Apr 30 16:14 /var/lib/mysql/dayu.000003
-rw-r-----. 1 mysql mysql 1.2K Apr 30 16:48 /var/lib/mysql/dayu.000004
-rw-r-----. 1 mysql mysql 177 May 5 12:03 /var/lib/mysql/dayu.000005
-rw-r----- 1 mysql mysql 3.8K May 8 16:55 /var/lib/mysql/dayu.000006
-rw-r----- 1 mysql mysql 30K May 28 09:29 /var/lib/mysql/dayu.000007
-rw-r----- 1 mysql mysql 98 May 8 16:55 /var/lib/mysql/dayu.index
-rw-r-----. 1 mysql mysql 291 May 5 12:03 /var/lib/mysql/ib_buffer_pool
-rw-r-----. 1 mysql mysql 12M May 28 09:29 /var/lib/mysql/ibdata1
-rw-r-----. 1 mysql mysql 48M May 28 09:29 /var/lib/mysql/ib_logfile0
-rw-r-----. 1 mysql mysql 48M Apr 27 14:10 /var/lib/mysql/ib_logfile1
-rw-r----- 1 mysql mysql 12M May 22 14:59 /var/lib/mysql/ibtmp1
-rw-r-----. 1 mysql mysql 794 Apr 30 13:39 /var/lib/mysql/mysql-bin.000001
-rw-r-----. 1 mysql mysql 177 Apr 30 14:52 /var/lib/mysql/mysql-bin.000002
-rw-r-----. 1 mysql mysql 38 Apr 30 13:41 /var/lib/mysql/mysql-bin.index
srwxrwxrwx 1 mysql mysql 0 May 8 13:38 /var/lib/mysql/mysql.sock
-rw------- 1 mysql mysql 5 May 8 13:38 /var/lib/mysql/mysql.sock.lock
-rw-------. 1 mysql mysql 1.7K Apr 27 14:10 /var/lib/mysql/private_key.pem
-rw-r--r--. 1 mysql mysql 451 Apr 27 14:10 /var/lib/mysql/public_key.pem
-rw-r--r--. 1 mysql mysql 1.1K Apr 27 14:10 /var/lib/mysql/server-cert.pem
-rw-------. 1 mysql mysql 1.7K Apr 27 14:10 /var/lib/mysql/server-key.pem
/var/lib/mysql/mysql:
total 12M
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 columns_priv.frm
-rw-r-----. 1 mysql mysql 0 Apr 27 14:10 columns_priv.MYD
-rw-r-----. 1 mysql mysql 4.0K Apr 27 14:10 columns_priv.MYI
-rw-r-----. 1 mysql mysql 9.4K Apr 27 14:10 db.frm
-rw-r-----. 1 mysql mysql 2.0K Apr 29 16:50 db.MYD
-rw-r-----. 1 mysql mysql 5.0K Apr 30 09:41 db.MYI
-rw-r-----. 1 mysql mysql 65 Apr 27 14:10 db.opt
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 engine_cost.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 engine_cost.ibd
-rw-r-----. 1 mysql mysql 10K Apr 27 14:10 event.frm
-rw-r-----. 1 mysql mysql 0 Apr 27 14:10 event.MYD
-rw-r-----. 1 mysql mysql 2.0K Apr 27 14:10 event.MYI
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 func.frm
-rw-r-----. 1 mysql mysql 0 Apr 27 14:10 func.MYD
-rw-r-----. 1 mysql mysql 1.0K Apr 27 14:10 func.MYI
-rw-r-----. 1 mysql mysql 35 Apr 30 15:40 general_log.CSM
-rw-r-----. 1 mysql mysql 0 Apr 27 14:10 general_log.CSV
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 general_log.frm
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 gtid_executed.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 gtid_executed.ibd
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 help_category.frm
-rw-r-----. 1 mysql mysql 112K Apr 27 14:10 help_category.ibd
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 help_keyword.frm
-rw-r-----. 1 mysql mysql 240K Apr 27 14:10 help_keyword.ibd
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 help_relation.frm
-rw-r-----. 1 mysql mysql 128K Apr 27 14:10 help_relation.ibd
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 help_topic.frm
-rw-r-----. 1 mysql mysql 9.0M Apr 27 14:10 help_topic.ibd
-rw-r-----. 1 mysql mysql 13K Apr 27 14:10 innodb_index_stats.frm
-rw-r-----. 1 mysql mysql 96K May 28 09:28 innodb_index_stats.ibd
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 innodb_table_stats.frm
-rw-r-----. 1 mysql mysql 96K May 28 09:28 innodb_table_stats.ibd
-rw-r-----. 1 mysql mysql 8.8K Apr 27 14:10 ndb_binlog_index.frm
-rw-r-----. 1 mysql mysql 0 Apr 27 14:10 ndb_binlog_index.MYD
-rw-r-----. 1 mysql mysql 1.0K Apr 27 14:10 ndb_binlog_index.MYI
-rw-r-----. 1 mysql mysql 8.4K Apr 27 14:10 plugin.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 plugin.ibd
-rw-r-----. 1 mysql mysql 9.8K Apr 27 14:10 proc.frm
-rw-r-----. 1 mysql mysql 294K Apr 27 14:10 proc.MYD
-rw-r-----. 1 mysql mysql 4.0K Apr 27 14:10 proc.MYI
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 procs_priv.frm
-rw-r-----. 1 mysql mysql 0 Apr 27 14:10 procs_priv.MYD
-rw-r-----. 1 mysql mysql 4.0K Apr 27 14:10 procs_priv.MYI
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 proxies_priv.frm
-rw-r-----. 1 mysql mysql 837 Apr 27 14:10 proxies_priv.MYD
-rw-r-----. 1 mysql mysql 9.0K Apr 27 14:10 proxies_priv.MYI
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 server_cost.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 server_cost.ibd
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 servers.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 servers.ibd
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 slave_master_info.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 slave_master_info.ibd
-rw-r-----. 1 mysql mysql 9.3K Apr 27 14:10 slave_relay_log_info.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 slave_relay_log_info.ibd
-rw-r-----. 1 mysql mysql 9.2K Apr 27 14:10 slave_worker_info.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 slave_worker_info.ibd
-rw-r-----. 1 mysql mysql 35 Apr 30 15:40 slow_log.CSM
-rw-r-----. 1 mysql mysql 0 Apr 27 14:10 slow_log.CSV
-rw-r-----. 1 mysql mysql 8.9K Apr 27 14:10 slow_log.frm
-rw-r-----. 1 mysql mysql 8.8K Apr 27 14:10 tables_priv.frm
-rw-r-----. 1 mysql mysql 1.9K Apr 27 14:10 tables_priv.MYD
-rw-r-----. 1 mysql mysql 9.0K Apr 27 14:10 tables_priv.MYI
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 time_zone.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 time_zone.ibd
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 time_zone_leap_second.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 time_zone_leap_second.ibd
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 time_zone_name.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 time_zone_name.ibd
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 time_zone_transition.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 time_zone_transition.ibd
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 time_zone_transition_type.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 time_zone_transition_type.ibd
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 user.frm
-rw-r-----. 1 mysql mysql 996 Apr 30 13:34 user.MYD
-rw-r-----. 1 mysql mysql 4.0K Apr 30 13:39 user.MYI
/var/lib/mysql/performance_schema:
total 1.1M
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 accounts.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 cond_instances.frm
-rw-r-----. 1 mysql mysql 61 Apr 27 14:10 db.opt
-rw-r-----. 1 mysql mysql 8.9K Apr 27 14:10 events_stages_current.frm
-rw-r-----. 1 mysql mysql 8.9K Apr 27 14:10 events_stages_history.frm
-rw-r-----. 1 mysql mysql 8.9K Apr 27 14:10 events_stages_history_long.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_stages_summary_by_account_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_stages_summary_by_host_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_stages_summary_by_thread_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_stages_summary_by_user_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_stages_summary_global_by_event_name.frm
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 events_statements_current.frm
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 events_statements_history.frm
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 events_statements_history_long.frm
-rw-r-----. 1 mysql mysql 9.8K Apr 27 14:10 events_statements_summary_by_account_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.9K Apr 27 14:10 events_statements_summary_by_digest.frm
-rw-r-----. 1 mysql mysql 9.8K Apr 27 14:10 events_statements_summary_by_host_by_event_name.frm
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 events_statements_summary_by_program.frm
-rw-r-----. 1 mysql mysql 9.8K Apr 27 14:10 events_statements_summary_by_thread_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.8K Apr 27 14:10 events_statements_summary_by_user_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.8K Apr 27 14:10 events_statements_summary_global_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.6K Apr 27 14:10 events_transactions_current.frm
-rw-r-----. 1 mysql mysql 9.6K Apr 27 14:10 events_transactions_history.frm
-rw-r-----. 1 mysql mysql 9.6K Apr 27 14:10 events_transactions_history_long.frm
-rw-r-----. 1 mysql mysql 9.3K Apr 27 14:10 events_transactions_summary_by_account_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.3K Apr 27 14:10 events_transactions_summary_by_host_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.3K Apr 27 14:10 events_transactions_summary_by_thread_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.3K Apr 27 14:10 events_transactions_summary_by_user_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.2K Apr 27 14:10 events_transactions_summary_global_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.2K Apr 27 14:10 events_waits_current.frm
-rw-r-----. 1 mysql mysql 9.2K Apr 27 14:10 events_waits_history.frm
-rw-r-----. 1 mysql mysql 9.2K Apr 27 14:10 events_waits_history_long.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_waits_summary_by_account_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_waits_summary_by_host_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_waits_summary_by_instance.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_waits_summary_by_thread_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_waits_summary_by_user_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 events_waits_summary_global_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 file_instances.frm
-rw-r-----. 1 mysql mysql 9.6K Apr 27 14:10 file_summary_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.7K Apr 27 14:10 file_summary_by_instance.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 global_status.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 global_variables.frm
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 host_cache.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 hosts.frm
-rw-r-----. 1 mysql mysql 9.1K Apr 27 14:10 memory_summary_by_account_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.0K Apr 27 14:10 memory_summary_by_host_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.1K Apr 27 14:10 memory_summary_by_thread_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.0K Apr 27 14:10 memory_summary_by_user_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.0K Apr 27 14:10 memory_summary_global_by_event_name.frm
-rw-r-----. 1 mysql mysql 8.8K Apr 27 14:10 metadata_locks.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 mutex_instances.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 objects_summary_global_by_type.frm
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 performance_timers.frm
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 prepared_statements_instances.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 replication_applier_configuration.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 replication_applier_status_by_coordinator.frm
-rw-r-----. 1 mysql mysql 8.8K Apr 27 14:10 replication_applier_status_by_worker.frm
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 replication_applier_status.frm
-rw-r-----. 1 mysql mysql 18K Apr 27 14:10 replication_connection_configuration.frm
-rw-r-----. 1 mysql mysql 9.0K Apr 27 14:10 replication_connection_status.frm
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 replication_group_members.frm
-rw-r-----. 1 mysql mysql 9.0K Apr 27 14:10 replication_group_member_stats.frm
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 rwlock_instances.frm
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 session_account_connect_attrs.frm
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 session_connect_attrs.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 session_status.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 session_variables.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 setup_actors.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 setup_consumers.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 setup_instruments.frm
-rw-r-----. 1 mysql mysql 8.6K Apr 27 14:10 setup_objects.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 setup_timers.frm
-rw-r-----. 1 mysql mysql 8.7K Apr 27 14:10 socket_instances.frm
-rw-r-----. 1 mysql mysql 9.6K Apr 27 14:10 socket_summary_by_event_name.frm
-rw-r-----. 1 mysql mysql 9.6K Apr 27 14:10 socket_summary_by_instance.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 status_by_account.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 status_by_host.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 status_by_thread.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 status_by_user.frm
-rw-r-----. 1 mysql mysql 8.8K Apr 27 14:10 table_handles.frm
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 table_io_waits_summary_by_index_usage.frm
-rw-r-----. 1 mysql mysql 11K Apr 27 14:10 table_io_waits_summary_by_table.frm
-rw-r-----. 1 mysql mysql 13K Apr 27 14:10 table_lock_waits_summary_by_table.frm
-rw-r-----. 1 mysql mysql 9.2K Apr 27 14:10 threads.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 users.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 user_variables_by_thread.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 variables_by_thread.frm
/var/lib/mysql/sys:
total 664K
-rw-r-----. 1 mysql mysql 61 Apr 27 14:10 db.opt
-rw-r-----. 1 mysql mysql 2.3K Apr 27 14:10 host_summary_by_file_io.frm
-rw-r-----. 1 mysql mysql 3.0K Apr 27 14:10 host_summary_by_file_io_type.frm
-rw-r-----. 1 mysql mysql 2.7K Apr 27 14:10 host_summary_by_stages.frm
-rw-r-----. 1 mysql mysql 4.1K Apr 27 14:10 host_summary_by_statement_latency.frm
-rw-r-----. 1 mysql mysql 4.4K Apr 27 14:10 host_summary_by_statement_type.frm
-rw-r-----. 1 mysql mysql 4.0K Apr 27 14:10 host_summary.frm
-rw-r-----. 1 mysql mysql 2.5K Apr 27 14:10 innodb_buffer_stats_by_schema.frm
-rw-r-----. 1 mysql mysql 2.8K Apr 27 14:10 innodb_buffer_stats_by_table.frm
-rw-r-----. 1 mysql mysql 5.2K Apr 27 14:10 innodb_lock_waits.frm
-rw-r-----. 1 mysql mysql 4.3K Apr 27 14:10 io_by_thread_by_latency.frm
-rw-r-----. 1 mysql mysql 4.1K Apr 27 14:10 io_global_by_file_by_bytes.frm
-rw-r-----. 1 mysql mysql 2.6K Apr 27 14:10 io_global_by_file_by_latency.frm
-rw-r-----. 1 mysql mysql 5.1K Apr 27 14:10 io_global_by_wait_by_bytes.frm
-rw-r-----. 1 mysql mysql 4.9K Apr 27 14:10 io_global_by_wait_by_latency.frm
-rw-r-----. 1 mysql mysql 3.4K Apr 27 14:10 latest_file_io.frm
-rw-r-----. 1 mysql mysql 3.4K Apr 27 14:10 memory_by_host_by_current_bytes.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 memory_by_thread_by_current_bytes.frm
-rw-r-----. 1 mysql mysql 3.4K Apr 27 14:10 memory_by_user_by_current_bytes.frm
-rw-r-----. 1 mysql mysql 3.4K Apr 27 14:10 memory_global_by_current_bytes.frm
-rw-r-----. 1 mysql mysql 827 Apr 27 14:10 memory_global_total.frm
-rw-r-----. 1 mysql mysql 10K Apr 27 14:10 metrics.frm
-rw-r-----. 1 mysql mysql 8.0K Apr 27 14:10 processlist.frm
-rw-r-----. 1 mysql mysql 1.1K Apr 27 14:10 ps_check_lost_instrumentation.frm
-rw-r-----. 1 mysql mysql 6.1K Apr 27 14:10 schema_auto_increment_columns.frm
-rw-r-----. 1 mysql mysql 3.6K Apr 27 14:10 schema_index_statistics.frm
-rw-r-----. 1 mysql mysql 3.7K Apr 27 14:10 schema_object_overview.frm
-rw-r-----. 1 mysql mysql 5.2K Apr 27 14:10 schema_redundant_indexes.frm
-rw-r-----. 1 mysql mysql 5.0K Apr 27 14:10 schema_table_lock_waits.frm
-rw-r-----. 1 mysql mysql 3.9K Apr 27 14:10 schema_table_statistics.frm
-rw-r-----. 1 mysql mysql 5.3K Apr 27 14:10 schema_table_statistics_with_buffer.frm
-rw-r-----. 1 mysql mysql 2.0K Apr 27 14:10 schema_tables_with_full_table_scans.frm
-rw-r-----. 1 mysql mysql 2.3K Apr 27 14:10 schema_unused_indexes.frm
-rw-r-----. 1 mysql mysql 3.0K Apr 27 14:10 session.frm
-rw-r-----. 1 mysql mysql 2.0K Apr 27 14:10 session_ssl_status.frm
-rw-r-----. 1 mysql mysql 6.9K Apr 27 14:10 statement_analysis.frm
-rw-r-----. 1 mysql mysql 3.7K Apr 27 14:10 statements_with_errors_or_warnings.frm
-rw-r-----. 1 mysql mysql 5.6K Apr 27 14:10 statements_with_full_table_scans.frm
-rw-r-----. 1 mysql mysql 3.4K Apr 27 14:10 statements_with_runtimes_in_95th_percentile.frm
-rw-r-----. 1 mysql mysql 4.3K Apr 27 14:10 statements_with_sorting.frm
-rw-r-----. 1 mysql mysql 4.3K Apr 27 14:10 statements_with_temp_tables.frm
-rw-r-----. 1 mysql mysql 8.5K Apr 27 14:10 sys_config.frm
-rw-r-----. 1 mysql mysql 96K Apr 27 14:10 sys_config.ibd
-rw-r-----. 1 mysql mysql 42 Apr 27 14:10 sys_config_insert_set_user.TRN
-rw-r-----. 1 mysql mysql 720 Apr 27 14:10 sys_config.TRG
-rw-r-----. 1 mysql mysql 42 Apr 27 14:10 sys_config_update_set_user.TRN
-rw-r-----. 1 mysql mysql 2.3K Apr 27 14:10 user_summary_by_file_io.frm
-rw-r-----. 1 mysql mysql 2.9K Apr 27 14:10 user_summary_by_file_io_type.frm
-rw-r-----. 1 mysql mysql 2.7K Apr 27 14:10 user_summary_by_stages.frm
-rw-r-----. 1 mysql mysql 4.1K Apr 27 14:10 user_summary_by_statement_latency.frm
-rw-r-----. 1 mysql mysql 4.4K Apr 27 14:10 user_summary_by_statement_type.frm
-rw-r-----. 1 mysql mysql 4.6K Apr 27 14:10 user_summary.frm
-rw-r-----. 1 mysql mysql 461 Apr 27 14:10 version.frm
-rw-r-----. 1 mysql mysql 3.5K Apr 27 14:10 wait_classes_global_by_avg_latency.frm
-rw-r-----. 1 mysql mysql 3.4K Apr 27 14:10 wait_classes_global_by_latency.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 waits_by_host_by_latency.frm
-rw-r-----. 1 mysql mysql 3.4K Apr 27 14:10 waits_by_user_by_latency.frm
-rw-r-----. 1 mysql mysql 2.4K Apr 27 14:10 waits_global_by_latency.frm
-rw-r-----. 1 mysql mysql 2.3K Apr 27 14:10 x@0024host_summary_by_file_io.frm
-rw-r-----. 1 mysql mysql 2.8K Apr 27 14:10 x@0024host_summary_by_file_io_type.frm
-rw-r-----. 1 mysql mysql 2.6K Apr 27 14:10 x@0024host_summary_by_stages.frm
-rw-r-----. 1 mysql mysql 3.9K Apr 27 14:10 x@0024host_summary_by_statement_latency.frm
-rw-r-----. 1 mysql mysql 4.2K Apr 27 14:10 x@0024host_summary_by_statement_type.frm
-rw-r-----. 1 mysql mysql 3.6K Apr 27 14:10 x@0024host_summary.frm
-rw-r-----. 1 mysql mysql 2.4K Apr 27 14:10 x@0024innodb_buffer_stats_by_schema.frm
-rw-r-----. 1 mysql mysql 2.7K Apr 27 14:10 x@0024innodb_buffer_stats_by_table.frm
-rw-r-----. 1 mysql mysql 5.0K Apr 27 14:10 x@0024innodb_lock_waits.frm
-rw-r-----. 1 mysql mysql 4.1K Apr 27 14:10 x@0024io_by_thread_by_latency.frm
-rw-r-----. 1 mysql mysql 3.8K Apr 27 14:10 x@0024io_global_by_file_by_bytes.frm
-rw-r-----. 1 mysql mysql 2.3K Apr 27 14:10 x@0024io_global_by_file_by_latency.frm
-rw-r-----. 1 mysql mysql 4.6K Apr 27 14:10 x@0024io_global_by_wait_by_bytes.frm
-rw-r-----. 1 mysql mysql 4.3K Apr 27 14:10 x@0024io_global_by_wait_by_latency.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 x@0024latest_file_io.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 x@0024memory_by_host_by_current_bytes.frm
-rw-r-----. 1 mysql mysql 2.9K Apr 27 14:10 x@0024memory_by_thread_by_current_bytes.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 x@0024memory_by_user_by_current_bytes.frm
-rw-r-----. 1 mysql mysql 3.1K Apr 27 14:10 x@0024memory_global_by_current_bytes.frm
-rw-r-----. 1 mysql mysql 765 Apr 27 14:10 x@0024memory_global_total.frm
-rw-r-----. 1 mysql mysql 7.5K Apr 27 14:10 x@0024processlist.frm
-rw-r-----. 1 mysql mysql 1.8K Apr 27 14:10 x@0024ps_digest_95th_percentile_by_avg_us.frm
-rw-r-----. 1 mysql mysql 844 Apr 27 14:10 x@0024ps_digest_avg_latency_distribution.frm
-rw-r-----. 1 mysql mysql 2.9K Apr 27 14:10 x@0024ps_schema_table_statistics_io.frm
-rw-r-----. 1 mysql mysql 2.5K Apr 27 14:10 x@0024schema_flattened_keys.frm
-rw-r-----. 1 mysql mysql 3.3K Apr 27 14:10 x@0024schema_index_statistics.frm
-rw-r-----. 1 mysql mysql 5.0K Apr 27 14:10 x@0024schema_table_lock_waits.frm
-rw-r-----. 1 mysql mysql 3.4K Apr 27 14:10 x@0024schema_table_statistics.frm
-rw-r-----. 1 mysql mysql 4.6K Apr 27 14:10 x@0024schema_table_statistics_with_buffer.frm
-rw-r-----. 1 mysql mysql 1.9K Apr 27 14:10 x@0024schema_tables_with_full_table_scans.frm
-rw-r-----. 1 mysql mysql 3.1K Apr 27 14:10 x@0024session.frm
-rw-r-----. 1 mysql mysql 6.6K Apr 27 14:10 x@0024statement_analysis.frm
-rw-r-----. 1 mysql mysql 3.6K Apr 27 14:10 x@0024statements_with_errors_or_warnings.frm
-rw-r-----. 1 mysql mysql 5.4K Apr 27 14:10 x@0024statements_with_full_table_scans.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 x@0024statements_with_runtimes_in_95th_percentile.frm
-rw-r-----. 1 mysql mysql 4.1K Apr 27 14:10 x@0024statements_with_sorting.frm
-rw-r-----. 1 mysql mysql 4.1K Apr 27 14:10 x@0024statements_with_temp_tables.frm
-rw-r-----. 1 mysql mysql 2.3K Apr 27 14:10 x@0024user_summary_by_file_io.frm
-rw-r-----. 1 mysql mysql 2.8K Apr 27 14:10 x@0024user_summary_by_file_io_type.frm
-rw-r-----. 1 mysql mysql 2.6K Apr 27 14:10 x@0024user_summary_by_stages.frm
-rw-r-----. 1 mysql mysql 3.9K Apr 27 14:10 x@0024user_summary_by_statement_latency.frm
-rw-r-----. 1 mysql mysql 4.2K Apr 27 14:10 x@0024user_summary_by_statement_type.frm
-rw-r-----. 1 mysql mysql 4.3K Apr 27 14:10 x@0024user_summary.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 x@0024wait_classes_global_by_avg_latency.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 x@0024wait_classes_global_by_latency.frm
-rw-r-----. 1 mysql mysql 3.0K Apr 27 14:10 x@0024waits_by_host_by_latency.frm
-rw-r-----. 1 mysql mysql 3.2K Apr 27 14:10 x@0024waits_by_user_by_latency.frm
-rw-r-----. 1 mysql mysql 2.2K Apr 27 14:10 x@0024waits_global_by_latency.frm
/var/lib/mysql/zxjt:
total 664K
-rw-r----- 1 mysql mysql 8.5K May 8 15:25 dayu_clone.frm
-rw-r----- 1 mysql mysql 112K May 8 15:25 dayu_clone.ibd
-rw-r----- 1 mysql mysql 8.4K May 8 15:56 dayu.frm
-rw-r----- 1 mysql mysql 112K May 8 15:56 dayu.ibd
-rw-r-----. 1 mysql mysql 65 Apr 27 21:42 db.opt
-rw-r----- 1 mysql mysql 8.5K May 8 15:33 insect.frm
-rw-r----- 1 mysql mysql 96K May 8 15:33 insect.ibd
-rw-r----- 1 mysql mysql 17K May 22 14:56 t.frm
-rw-r----- 1 mysql mysql 144K May 22 14:58 t.ibd
-rw-r----- 1 mysql mysql 8.5K May 28 09:27 z.frm
-rw-r----- 1 mysql mysql 128K May 28 09:29 z.ibd
/var/lib/mysql/zxjt_load:
total 220K
-rw-r----- 1 mysql mysql 8.4K May 8 16:09 dayu.frm
-rw-r----- 1 mysql mysql 96K May 8 16:09 dayu.ibd
-rw-r----- 1 mysql mysql 65 May 8 15:41 db.opt
-rw-r----- 1 mysql mysql 8.4K May 8 16:00 student.frm
-rw-r----- 1 mysql mysql 96K May 8 16:03 student.ibd
*****************************
区
*****************************
在mysql中区的大小都是固定的,大小都是1M。
创建的表默认大小是96K,先用32个页来存放数据,使用完之后才是64个连续页的申请。
*****************************
块
*****************************
mysql> show variables like '%innodb_page_size%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| innodb_page_size | 16384 |
+------------------+-------+
1 row in set (0.00 sec)
mysql>
*****************************
行
*****************************
每个page中存放的行数是有上限的,16384/2-200=7992行。
Row_format记录的是行格式
mysql> show table status like '%z%';
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
| z | InnoDB | 10 | Dynamic | 3 | 5461 | 16384 | 0 | 32768 | 0 | NULL | 2019-05-28 09:27:53 | 2019-05-28 09:29:01 | NULL | latin1_swedish_ci | NULL | | |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
1 row in set (0.02 sec)
mysql>
*****************************
数据行记录方式
*****************************
compact行记录方式
redundant行记录格式
compressed和dynamic行记录方式
create table mytest (
t1 varchar(10),
t2 varchar(10),
t3 char(10),
t4 varchar(10)) engine=innodb charset=latin1 row_format=compact;
insert into mytest values('a','bb','bb','ccc');
insert into mytest values('d','ee','ee','fff');
insert into mytest values('d',null,null,'fff');
hexdump -C -v mytest.ibd > mytest.txt 【这里dump出的并不是单个page】
0000c050 00 02 00 f2 00 00 00 34 00 00 00 02 00 32 01 00 |.......4.....2..|
0000c060 02 00 1e 69 6e 66 69 6d 75 6d 00 04 00 0b 00 00 |...infimum......|
0000c070 73 75 70 72 65 6d 75 6d 03 02 01 00 00 00 10 00 |supremum........|
0000c080 2c 00 00 00 00 03 1b 00 00 00 00 25 c0 a9 00 00 |,..........%....|
0000c090 01 1d 01 10 61 62 62 62 62 20 20 20 20 20 20 20 |....abbbb |
0000c0a0 20 63 63 63 03 02 01 00 00 00 18 00 2b 00 00 00 | ccc........+...|
0000c0b0 00 03 1c 00 00 00 00 25 c1 aa 00 00 01 1e 01 10 |.......%........|
0000c0c0 64 65 65 65 65 20 20 20 20 20 20 20 20 66 66 66 |deeee fff|
0000c0d0 03 01 06 00 00 20 ff 98 00 00 00 00 03 1d 00 00 |..... ..........|
0000c0e0 00 00 25 c6 ad 00 00 01 21 01 10 64 66 66 66 00 |..%.....!..dfff.|
0000c0f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0000c100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0000c110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*****************************
数据页
*****************************
create table t1
(a int unsigned not null auto_increment,
b char(10),
primary key(a)) engine=innodb charset=UTF8;
delimiter $$
create procedure load_t1 (count int unsigned)
begin
set @c = 0;
while @c < count do
insert into t1
select null,repeat(char(97+rand()*26),10);
set @c=@c+1;
end while;
end;
$$;
insert into t1 select null,repeat(char(97+rand()*26),10);
mysql> select * from t1;
+----+------------+
| a | b |
+----+------------+
| 1 | uuuuuuuuuu |
| 2 | ssssssssss |
| 3 | eeeeeeeeee |
| 4 | ssssssssss |
| 5 | zzzzzzzzzz |
| 6 | vvvvvvvvvv |
| 7 | eeeeeeeeee |
| 8 | iiiiiiiiii |
| 9 | cccccccccc |
| 10 | llllllllll |
+----+------------+
10 rows in set (0.00 sec)
mysql> select char(97+rand()*26);
+--------------------+
| char(97+rand()*26) |
+--------------------+
| y |
+--------------------+
1 row in set (0.00 sec)
mysql> select char(97);
+----------+
| char(97) |
+----------+
| a |
+----------+
1 row in set (0.00 sec)
mysql> select rand();
+--------------------+
| rand() |
+--------------------+
| 0.4113105371699767 |
+--------------------+
1 row in set (0.00 sec)
mysql> select rand();
+---------------------+
| rand() |
+---------------------+
| 0.23754936571936064 |
+---------------------+
1 row in set (0.00 sec)
mysql> select rand();
+--------------------+
| rand() |
+--------------------+
| 0.9538152478205182 |
+--------------------+
1 row in set (0.00 sec)
[root@mysql1 py_innodb_page_info-master]# ./py_innodb_page_info.py -v /var/lib/mysql/zxjt/t1.ibd
page offset 00000000, page type <File Space Header>
page offset 00000001, page type <Insert Buffer Bitmap>
page offset 00000002, page type <File Segment inode>
page offset 00000003, page type <B-tree Node>, page level <0000>
page offset 00000000, page type <Freshly Allocated Page>
page offset 00000000, page type <Freshly Allocated Page>
Total number of page: 6:
Freshly Allocated Page: 2
Insert Buffer Bitmap: 1
File Space Header: 1
B-tree Node: 1
File Segment inode: 1