当前位置:网站首页>MySQL data directory (1) -- database structure (24)
MySQL data directory (1) -- database structure (24)
2022-07-26 13:18:00 【User 9919783】
In the last article, we said that both index space and time will be consumed , Don't build indexes .
When the column needs to be used as a condition , Sort , When grouping, you can choose the front row as the index .
It also depends on the cardinality at the forefront , The larger the base, the more suitable for indexing .
Avoid when querying % On the front .
When querying the range, only the leftmost side will trigger the index , Unless the precision value is specified .
The index exists independently , You can't calculate or calculate , This will not trigger the index .
Long string query , It costs a lot of time and space , At this time, you can create hash Index or select the first few digits of the string for index sorting , If you use string prefix as index , The sorting will be invalid , Sort by file .
Try to use overlay index , It can avoid the second query of the back table .
B+ Tree selection index (2)---mysql From entry to mastery ( 23 )
Mysql Data directory
We all know innoDB and myISAM Storage engines store data on disk , And the operating system manages the disk is the file system , So it's like nnoDB and myISAM Such storage engines store data in file systems . When we read data , Just read the data from the file system , When we write data , The storage engine will write data to the file system .
Data directory
Mysql At startup , Will download some files in a directory of the file system , Then the data generated during the operation will also be placed in this directory , It is called data directory . We installed mysql When it's time to specify mysql Installation directory , There are many executable files , The data directory we are talking about here must be separated from the installation directory , How do we look at ourselves mysql What about your data directory ? The system variable corresponding to the data directory is datadir, As long as we input the current command, we can see :
mysql> show variables like 'datadir';
+---------------+------------------------+
| Variable_name | Value |
+---------------+------------------------+
| datadir | /usr/local/mysql/data/ |
+---------------+------------------------+
1 row in set (0.00 sec)The structure of the data directory
that mysql What data will be generated when running ? Of course, the database we created , surface , View , trigger , Other user data , In addition to these data ,mysql For better operation , Increase of efficiency , There will also be some additional data .
The representation of a database in a file system
Create a table from the specified database , So let's start with creating a database , The representation of database in file system begins , We are create database ‘’, What happened ?
[email protected] mysql % cd data
[email protected] data % ls
B-D226JG5H-0020.local.err mysql
B-D226JG5H-0020.local.pid mysqld.local.err
auto.cnf mysqld.local.pid
dev mysqld_safe.pid
ib_buffer_pool performance_schema
ib_logfile0 sys
ib_logfile1 testmac
ibdata1 utf_8
ibtmp1View data files data Under the table of contents , We can see the various databases we have created , So when you run create database '' Of When :
1) In the data directory , Create a subdirectory with the same name as the database .
2) Enter the specified database file , You can see the default created db.opt file , It stores the rules of the current database , features , Such as comparison rules , Character set, etc. .
Table's position in the file system
The table is divided into two parts :1) Table structure file .2) Table data file .
When we create table '' A watch time , It will be in the database file directory , Create a table name .frm The file of . For example, we have index_page_tb, So in utf_8 There will be a in the directory of index_page_tb.frm The file records the structure of the current table , For example, row rules with tables , Character set , The data type of each column , Index, etc. . It is worth noting that innoDB and mISAM Will create .frm File to record the structure of the current table , But the stored data is different . In the next article, let's look at the storage file of data .( Be careful :.frm It's binary , If you open it directly, it will be garbled )
边栏推荐
- 0 basic programming resources (collect first ~ read slowly ~)
- [upper computer tutorial] Application of integrated stepping motor and Delta PLC (as228t) under CANopen communication
- 银行业客户体验管理现状与优化策略分析
- Does anyone know where the retract of flinksql can be specified? Only api code settings can be seen in online materials
- [applet] why can't the onreachbottom event be triggered? (one second)
- Sword finger offer (21): push in and pop-up sequence of stack
- LeetCode 217. 存在重复元素
- 目标检测网络R-CNN 系列
- Leetcode 263. ugly number
- How to remove underline and color when there is focus in the shutter textfield
猜你喜欢
2022 employment season! Adobe helps creative industry workers break through the shackles of skills and return to the source of ability

panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)

Learn about Pinia state getters actions plugins

Dimension disaster dimension disaster suspense

Kubelet CRI container runtime

Huawei recruited "talented teenagers" twice this year; 5.4 million twitter account information was leaked, with a selling price of $30000; Google fired engineers who believed in AI consciousness | gee

概率论与数理统计

Target detection network r-cnn series

【TypeScript】TypeScript常用类型(上篇)

Shutter background graying effect, how transparency, gray mask
随机推荐
pomerium
StreamNative 团队文化:一家“透明”的公司
Dimension disaster dimension disaster suspense
如何构建以客户为中心的产品蓝图:来自首席技术官的建议
【5GC】什么是5G切片?5G切片如何工作?
Exploration on cache design optimization of community like business
0 basic programming resources (collect first ~ read slowly ~)
V00 - do whatever you want when you are old
Emotion analysis model based on Bert
银行业客户体验管理现状与优化策略分析
Leetcode 1523. count odd numbers within the interval
C regards type as generic type T and uses it as generic type of method
Leetcode 263. ugly number
同花顺开的账户安全吗?
JSON格式执行计划(6)—mysql执行计划(五十二)
基于C#实现的学生考试系统
Is the account opened by flush safe?
Kubernetes Flannel:HOST-GW模式
1312_适用7z命令进行压缩与解压
Router. Push(), router. Reply(), router. Go()