InnoDB1

create table(

)engine= Engine_name

key:

好处:

  • crash recovery提交改变,undo 未提交
  • 主键自动做索引,where,order,group,join快

实践

  • 自增列和频繁查询做主键
  • join列加外键
  • 关闭自动提交set autocommit=1;
  • 将多个dml加入事务,start transaction 和commit
  • 不要使用lock tables,准备更新用select ... for update
    [http://chenzhou123520.iteye.com/blog/1860954 ]

ACID

  • 原子性 事务 commit,rollback
    -一致性 灾难保护 doublewrite buffer,crash recovery
    -隔离性 事务隔离等级 SET ISOLATION LEVEL
    -持久性

MVCC

link1
link2
link3
innodb为每行增加3个字段:

  • DB_TRX_ID:最后增删改行的事务ID
  • DB_ROLL_PTR:回滚指针,指向undo log
  • DB_ROW_ID:新行加入,单调增加

undo log分为insert undo log和update undo log

SQL删除不是物理删除

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容