http://blog.csdn.net/yunhua_lee/article/details/8239145

原文:http://dev.mysql.com/doc/refman/5.5/en/innodb-default-se.html
Best Practices for InnoDB Tables
If you have been using InnoDB for a long time, you already know about features like transactions and foreign keys. If not, read about them throughout this chapter. To make a long story short:

1) Specify a primary key for every table using the most frequently queried column or columns, or an auto-increment value if there isn't an obvious primary key.
指定主键:使用最频繁查询的一个或者多个列作为主键,如果没有,就使用自增id作为主键

2) Embrace the idea of joins, where data is pulled from multiple tables based on identical ID values from those tables. For fast join performance, define foreign keys on the join columns, and declare those columns with the same datatype in each table. The foreign keys also propagate deletes or updates to all affected tables, and prevent insertion of data in a child table if the corresponding IDs are not present in the parent table.
拥抱join:当数据从多个表里面按照相同的ID值取出来的时候,优先使用join,可以使用外键来提高join的性能。

3) Turn off autocommit. Committing hundreds of times a second puts a cap on performance (limited by the write speed of your storage device).
关闭autocommit:每秒提交几百次会限制性能。
(译者注:业务系统建议不要关闭,否则编程比较麻烦,批量导入数据的时候可以关闭,然后定时或者定量commit)

4) Bracket sets of related changes, logical units of work, with START TRANSACTION and COMMIT statements. While you don't want to commit too often, you also don't want to issue huge batches of INSERT, UPDATE, or DELETEstatements that run for hours without committing.
使用事务提交,避免频繁提交

5) Stop using LOCK TABLE statements. InnoDB can handle multiple sessions all reading and writing to the same table at once, without sacrificing reliability or high performance. To get exclusive write access to a set of rows, use theSELECT ... FOR UPDATE syntax to lock just the rows you intend to update.
不要使用LOCK TABLE操作,Innodb的机制能够支持高并发操作,且不损失可靠性和性能。推荐使用SELECT....FOR UPDATE

6) Enable the innodb_file_per_table option to put the data and indexes for individual tables into separate files, instead of in a single giant system tablespace. (This setting is required to use some of the other features, such as table compression and fast truncation.)
打开innodb_file_per_table选项

 
 

一些mysql innodb的建议的更多相关文章

  1. Mysql InnoDB 共享表空间和独立表空间

    前言:学习mysql的时候总是习惯性的和oracle数据库进行比较.在学习mysql InnoDB的存储结构的时候也免不了跟oracle进行比较.Oracle的数据存储有表空间.段.区.块.数据文件: ...

  2. MySQL Innodb数据库性能实践——热点数据性能

    摘要: 对于大部分的应用来说,都存在热点数据的访问,即:某些数据在一定时间内的访问频率要远远高于其它数据. 常见的热点数据有“最新的新闻”.“最热门的新闻”.“下载量最大”的电影等. 为了了解MySQ ...

  3. MySQL 运行环境建议规范

    一.操作系统环境 操作系统版本选择 CentOS/RHRL/ORACLE Linux 5.x/6.x x86_64 发行版 建议磁盘分区规则 MySQL 运行环境建议规范 挂载点 大小 分区类型 分区 ...

  4. MySQL InnoDB存储引擎中的锁机制

    1.隔离级别 Read Uncommited(RU):这种隔离级别下,事务间完全不隔离,会产生脏读,可以读取未提交的记录,实际情况下不会使用. Read Committed (RC):仅能读取到已提交 ...

  5. MySQL InnoDB 修改表列Online DDL

    概述 一般来说数据库结构一经设计,不能轻易更改,因为更改DDL(Data Definition Language)操作代价很高,所以在进行数据库结构设计时需要谨慎. 但是业务发展是未知的,特别是那些变 ...

  6. MySQL InnoDB 存储引擎探秘

    在MySQL中InnoDB属于存储引擎层,并以插件的形式集成在数据库中.从MySQL5.5.8开始,InnoDB成为其默认的存储引擎.InnoDB存储引擎支持事务.其设计目标主要是面向OLTP的应用, ...

  7. 浅析MySQL InnoDB的隔离级别

    MySQL InnoDB存储引擎中事务的隔离级别有哪些?对应隔离级别的实现机制是什么? 本文就将对上面这两个问题进行解答,分析事务的隔离级别以及相关锁机制. 隔离性简介 隔离性主要是指数据库系统提供一 ...

  8. [MySQL]InnoDB引擎的行锁和表锁

    1.行锁和表锁 在mysql 的 InnoDB引擎支持行锁,与Oracle不同,mysql的行锁是通过索引加载的,即是行锁是加在索引响应的行上的,要是对应的SQL语句没有走索引,则会全表扫描, 行锁则 ...

  9. Mysql InnoDB三大特性-- double write

    转自:http://www.ywnds.com/?p=8334 一.经典Partial page write问题? 介绍double write之前我们有必要了解partial page write( ...

随机推荐

  1. TCP连接状态详解

    tcp状态: LISTEN:侦听来自远方的TCP端口的连接请求 SYN-SENT:再发送连接请求后等待匹配的连接请求 SYN-RECEIVED:再收到和发送一个连接请求后等待对方对连接请求的确认 ES ...

  2. vue -- config.js 配置跨域文件

    1.在使用vue开发的时候经常要涉及到跨域的问题,其实在vue cli中是有我们设置跨域请求的文件的. 2.当跨域无法请求的时候我们可以修改工程下config文件夹下的index.js中的dev -- ...

  3. 深入理解Android(2)——理解Android中的JNI(中)

    阳光小强参加了CSDN博客之星评选,如果你觉得阳光小强的博客对你有所帮助,为小强投上一票吧:http://vote.blog.csdn.net/blogstar2014/details?usernam ...

  4. hadoop常用指令

    1.格式化名称节点:hadoop namenode -format 2.操作hadoop文件系统:hadoop fs -ls / 3.设置ubuntu默认以命令行方式启动 sudo gedit /et ...

  5. OSI模型与TCP/IP协议族

    OSI模型与TCP/IP协议族 年之后,TCP/IP协议族逐渐成为占主导的商用体系结构,广泛应用于Internet中,并通过广泛的測试.而OSI模型从来没有被全然实现过. 一.OSI模型: OSI与I ...

  6. ubuntu-文件管理、编辑

    1.创建单层文件夹 mkdir test 如果你想要创建多层文件夹,这时候你需要添加一个参数-p mkdir -p t1/t2/t3 如果你不加-p的话,它会提示说找不到目录 2.分屏查看内容 mor ...

  7. 《四》JAVA 字符输入输出流

    那么这篇博客我们讲的是字节输入输出流:Reader.Writer(下图红色长方形框内),红色椭圆框内是其典型实现(FileReader.FileWriter) ①.为什么要使用字符流? 因为使用字节流 ...

  8. 如何运行vue项目(维护他人的项目)

    假如你是个小白,在公司接手他人的项目,这个时候,该怎么将这个项目跑通? 前提: 首先,这个教程主要针对vue小白,并且不知道安装node.js环境的.言归正传,下面开始教程:在维护项目之前,需要把所有 ...

  9. PatentTips - Interrupt redirection for virtual partitioning

    BACKGROUND The present disclosure relates to the handling of interrupts in a environment that utiliz ...

  10. 洛谷——P1316 丢瓶盖

    https://www.luogu.org/problem/show?pid=1316 题目描述 陶陶是个贪玩的孩子,他在地上丢了A个瓶盖,为了简化问题,我们可以当作这A个瓶盖丢在一条直线上,现在他想 ...