InnoDB -- 行记录格式
本文主要介绍InnoDB存储引擎的行记录格式ROW_FORMAT
分类
Named File Format
InnoDB早期的文件格式(页格式)为Antelope,可以定义两种行记录格式,分别是Compact和Redundant
Named File Format为了解决不同版本下页结构的兼容性,在Barracuda可以定义两种新的行记录格式Compressed和Dynamic
变量为innodb_file_format和innodb_default_row_format
123456789101112131415mysql> SHOW VARIABLES LIKE 'innodb_file_format';+--------------------+-----------+| Variable_name | Value |+--------------------+-----------+| innodb_file_format | Barracuda |+--------------------+-----------+1 row in set ( ...
InnoDB -- 逻辑存储
本文主要介绍InnoDB存储引擎的逻辑存储结构
逻辑存储结构
Tablespace
Tablespace是InnoDB存储引擎逻辑存储结构的最高层,所有数据都存放在Tablespace中
分类
System Tablespace
Separate Tablespace
General Tablespace
System Tablespace
System Tablespace即我们常见的共享表空间,变量为innodb_data_file_path,一般为ibdata1文件
里面存放着undo logs,change buffer,doublewrite buffer等信息(后续将详细介绍),在没有开启file-per-table的情况下,还会包含所有表的索引和数据信息
没有开启file-per-table时存在的问题
所有的表和索引都会在System Tablespace中,占用空间会越来越大
碎片越来越多(如truncate table时,占用的磁盘空间依旧保留在System Tablespace)
12345678910111213141516171819mysql> SHO ...
Git -- Git Flow
主要介绍Git Flow中Feature分支、Release分支、Hotfix分支的流程
Git Flow
初始化仓库git flow init:初始化仓库,支持GitFlow分支模型
12345678910111213141516171819202122232425262728293031323334353637383940414243444546$ git clone https://github.com/hzmajia/gitflow-example.gitCloning into 'gitflow-example'...warning: You appear to have cloned an empty repository.Checking connectivity... done.$ cd gitflow-example && git flow initNo branches exist yet. Base branches must be created now.Branch name for production releases: [maste ...
Git -- 仓库瘦身
本文主要介绍两种减少.git仓库磁盘大小的两种方式:git gc和git prune
git gc
适用于存在大文件,且多次提交都只是轻微改动该大文件的场景,因为这些提交都会生成大小相近的大文件blob对象,非常占用磁盘空间
Git最初向磁盘中存储对象使用松散的格式,后续会将多个对象打包为一个二进制的包文件(packfile),以节省磁盘空间
.pack文件存储了对象的内容
.idx文件存储了包文件的偏移信息,用于索引具体的对象
打包对象时,查找命名和大小相近的文件,保留文件不同版本之间的差异(最新一版保存完整内容,访问频率最高)
verify-pack -v *.idx:查看压缩包内容
添加随机(压缩率低)字符大文件bigfile并提交
1234567891011121314151617181920212223242526272829303132333435363738$ git initInitialized empty Git repository in /home/zhongmingmao/demo/.git/$ dd if=/dev/urandom of=./bigfile bs=1k ...
Git -- 对象
本文将主要介绍blob对象,tree对象,commit对象,tag对象
.git核心
.git/HEAD:一般情况下,指向分支引用;如果直接指向提交对象,将处于detached HEAD状态
.git/index:暂存区信息
.git/objects:Git对象数据
.git/refs:引用信息,包括分支引用,标签引用等
1234567891011121314151617181920212223242526272829303132333435363738$ git log --oneline --decorate --graph --all* ae432e4 (HEAD -> master) echo master > file* daa44e8 add file$ ls .gitbranches COMMIT_EDITMSG config description HEAD hooks index info logs objects ORIG_HEAD refs rr-cache$ cat .git/HEADref: refs/heads/master$ cat ...
Git -- 合并
本文主要介绍合并中断,查看冲突,冲突相关的提交,撤销合并
中断合并git merge --abort:当出现冲突时,放弃当前合并,尝试恢复到合并前的状态
1234567891011121314151617181920212223242526272829303132$ git branch -v dev 43b3f7b echo dev > file* master 3f112d7 echo master > file$ git diff dev # conflict existsdiff --git a/file b/fileindex 38f8e88..1f7391f 100644--- a/file+++ b/file@@ -1 +1 @@-dev+master$ git merge devAuto-merging fileCONFLICT (content): Merge conflict in fileAutomatic merge failed; fix conflicts and then commit the result.$ gstOn branch masterY ...
Git -- Reset
本文主要介绍通过reset如何将 HEAD重置到特定的状态
常见工作流程
三个区域HEAD:存储在.git目录,上一次提交对象,下一次提交对象的父提交对象Index:存储在.git目录,暂存区域,用于下一次提交Working Directory:实际的文件
Working Directory->Index->HEADv1 : touch file.txtgit init后尚未有commit,此时master指向不明确
1234567$ git init$ touch file.txt$ gst -sb## Initial commit on master?? file.txt
v1 : git add12345$ git add file.txt$ gst -sb## Initial commit on masterA file.txt
v1 : git commit1234567891011$ git commit -m 'file.txt v1'[master (root-commit) a5c8857] file.txt v1 1 file chang ...
Git -- 重写提交历史
本文将通过介绍通过rebase和filter-branch重写提交历史,但两者都会新建提交对象,谨慎使用,尤其是提交历史已共享的情况下
交互式rebasegit rebase -i,基于某个提交对象开始,通过交互的方式,依次进行rebaseRebase的内容请参照「Git++ - 分支」
12345678910111213141516171819202122232425262728$ git log --oneline --decorate --graph --all* 3b1df9b (HEAD -> master) C4* bed6252 C3* 2b17907 C2* 4c02e18 C1* b71fde1 C0$ git rebase -i HEAD~3 # rebase onto (4c02e18 C1)reword 2b17907 C2 # editedreword bed6252 C3 # editedpick 3b1df9b C4# Rebase 4c02e18..3b1df9b onto 4c02e18 (3 command(s))## Commands:# p, pick = ...
Git -- Stash
本文主要介绍stash操作,常用于储藏未完成的工作,以免将脏状态保存为一个提交
git stashgit stash:储藏working directory和index的当前状态(不包括untracked文件)git stash apply:仅应用working directory的修改,不应用index的修改git stash list:stash列表git stash drop:删除stash
1234567891011121314151617181920212223242526272829303132$ gst -sb## masterM a.txt M b.txt$ git stash list # Stdout print nothing$ git stash # save working directory and index stateSaved working directory and index state WIP on master: 2e5960b add a.txt b.txtHEAD is now at 2e5960b add a.txt b.txt$ gstOn bra ...
Git -- 引用和提交区间
本文主要介绍常见的引用(commit对象及其祖先的的引用,branch引用,HEAD引用等)和提交区间commit对象,tag对象的内容请参照「Git++ - 对象」
引用commit对象引用git show:显示Git对象信息
1234567891011$ git log --oneline --decorate --graph --all* 4f6c14f (HEAD -> master) add README.md$ git show --oneline -s 4f6c14f4f6c14f add README.md$ git show --oneline -s HEAD4f6c14f add README.md$ git show --oneline -s master4f6c14f add README.md
commit对象祖先的引用
在Fast Forward Merge中,只有一个父提交对象,第一父提交对象在Recursive Merge中,合并操作发生时的当前分支所指向的提交对象是第一父提交对象,被合并的分支所指向的提交对象是第二父提交对象
HEAD^:HEAD的第一父提交 ...