当前位置:网站首页>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 )
边栏推荐
- B+树索引使用(9)分组、回表、覆盖索引(二十一)
- 终极套娃 2.0 | 云原生交付的封装
- Kubernetes ---- life cycle introduction of PV and PVC
- jvm:类加载子系统干什么的?由什么组成?需要记住哪些八股文?
- The parent component accesses the methods or parameters of the child component (the child component exposes the method defineexpose)
- 基于C#实现的学生考试系统
- MySQL data directory (3) -- table data structure MyISAM (XXVI)
- 如何面对科技性失业?
- After being fined "paid leave" for one month, Google fired him who "loves" AI
- Is the account opened by flush safe?
猜你喜欢

Hcip day 12 notes sorting (BGP Federation, routing rules)

Elementary notes of binary tree

解决远程主机无法连接mysql数据库的问题
![[applet] why can't the onreachbottom event be triggered? (one second)](/img/da/3641040c63f6db4d227dcf2ff89919.png)
[applet] why can't the onreachbottom event be triggered? (one second)

学习pinia 介绍-State-Getters-Actions-Plugins

The difference between $route and $route

C regards type as generic type T and uses it as generic type of method

Hcip day 11 comparison (BGP configuration and release)

基于WebRTC和WebSocket实现的聊天系统

One stroke problem (Chinese postman problem)
随机推荐
[typescript] typescript common types (Part 2)
解决远程主机无法连接mysql数据库的问题
牛客刷SQL---2
B+ tree index use (6) leftmost principle -- MySQL from entry to proficiency (18)
Use positioning to realize left, middle and right layout, and the middle content is adaptive
jvm:类加载子系统干什么的?由什么组成?需要记住哪些八股文?
Why do you want to make "secret comments"?
Slam 02. overall framework
B+树挑选索引(2)---mysql从入门到精通(二十三)
基于Bézier曲线的三维造型与渲染
3D modeling and rendering based on B é zier curve
(int argc, char** argv) command line parameters in visual stdio (VS)
The child component triggers the defineemits of the parent component: the child component passes values to the parent component
AI theory knowledge map 1 Foundation
Leetcode 2119. number reversed twice
概要设计说明书
12-GuliMall 后台管理中商品系统的品牌管理
B+树索引使用(6)最左原则 --mysql从入门到精通(十八)
Is the account opened by flush safe?
1312_适用7z命令进行压缩与解压