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选项

转载于:https://www.cnblogs.com/charlesblc/p/6669844.html

一些mysql innodb的建议相关推荐

  1. 浅析MySQL InnoDB的隔离级别

    前言 还是老规矩,首先提出两个待解决的问题: MySQL InnoDB存储引擎中事务的隔离级别有哪些? 对应隔离级别的实现机制是什么? 本文就将对上面这两个问题进行解答,分析事务的隔离级别以及相关锁机 ...

  2. 论 MySql InnoDB 如何通过插入意向锁控制并发插入

    前言 在讲解之前,先来思考一个问题--假设有用户表结构如下: MySql,InnoDB,Repeatable-Read:users(id PK, name, age KEY) id name age ...

  3. 如何不停机迁移一个mysql INNODB 数据库?

    2019独角兽企业重金招聘Python工程师标准>>> 如何不停机迁移一个mysql INNODB 数据库? http://www.itpub.net/thread-1776724- ...

  4. Mysql+innodb数据存储逻辑

    Mysql+innodb数据存储逻辑. 表空间由段,区,页组成 ibdata1:共享表空间.即所有的数据都存放在这个表空间内.如果用户启用了innodb_file_per_table,则每张表内的数据 ...

  5. MySQL InnoDB的缓冲池之预读失效和缓存池污染

    InnoDB的缓存池作用: 缓存表数据和索引数据,把磁盘上的数据加载到缓冲池中,避免每次都进行磁盘IO,起到加速访问的效果. LRU算法(Least recently used): 把入缓存池的页放在 ...

  6. MySQL InnoDB Memcached Plugin在Oray公司的实践

    1.应用背景介绍 我所在职的Oray是一家提供各种互联网服务且具有海量用户的企业,我们也一直在实践各种新技术新架构:缓存方面,我们从memcached.ttserver.redis等都有较多应用,其中 ...

  7. mysql innodb隔离级别_浅析MySQL InnoDB的隔离级别

    本文就将对上面这两个问题进行解答,分析事务的隔离级别以及相关锁机制. 隔离性简介 隔离性主要是指数据库系统提供一定的隔离机制,保证事务在不受外部并发操作影响的"独立"环境执行,意思 ...

  8. 面试:MySQL InnoDB 事务隔离

    面试:MySQL InnoDB 事务隔离 几种隔离级别 事务的隔离性是数据库处理数据的几大基础之一,而隔离级别其实就是提供给用户用于在性能和可靠性做出选择和权衡的配置项. ISO 和 ANIS SQL ...

  9. mysql innodb 缓存设置_数据库分享一: MySQL的Innodb缓存相关优化

    无论是对于哪一种数据库来说,缓存技术都是提高数据库性能的关键技术,物理磁盘的访问速度永 远都会与内存的访问速度永远都不是一个数量级的.通过缓存技术无论是在读还是写方面都可以大大提 高数据库整体性能. ...

最新文章

  1. Apache Spark源码走读之8 -- Spark on Yarn
  2. RDA5807 FM收音机模块
  3. 《重返人类演化现场》阅读笔记
  4. sql azure 语法_使用Azure Data Studio从SQL Server数据创建图表
  5. Open3D 凸包算法
  6. 【python写一个无限弹窗】
  7. BM3D、域变换与Non-Local
  8. c语言搜索算法伪代码,FFT算法伪代码
  9. 特斯拉Model 3进化不止 传统车企到底应该学什么?
  10. Picgo 水印制作教程
  11. 苹果新产品中的机器学习算法
  12. 【转】 计算机视觉、图像处理学习资料汇总
  13. Google内部流传的反多样性文章(10页完整版中文翻译)
  14. 数字藏品平台金乌元宇助力中国数字文创发展
  15. 2020年实体店怎么营销推广获客
  16. [Leetcode]数据结构之数组——python版本
  17. mysql 星 拓扑_mysql数据库常用拓扑结构
  18. Dynamsoft 条码阅读器,实现条码扫描
  19. Android实战之小说阅读器,带有水平翻页,记录上次读取页码数
  20. 高数 limx→0[cos(sinx)-cosx]/(1-cosx)sinx.sinx

热门文章

  1. 招行java开发面试,面经:Java后台开发-招行网络科技
  2. ps背景不变换字_分享五个超级实用的PS小技巧
  3. Java学习总结:44(文件复制案例)
  4. matlab整型和浮点的区别,技术帖 | 心理学MATLAB初学者教程--简单数据类型介绍(逻辑型数据,整型/浮点型数据,字符型)......
  5. vanpopup 高度_解决VantUI popup 弹窗不弹出或无蒙层的问题
  6. 宝塔的服务忽然挂掉解决方法
  7. 3 OC 属性和方法
  8. Java单元测试之JUnit4详解
  9. Microsoft Visual Studio 2012 添加实体数据模型
  10. Socketserver 笔记