zoukankan      html  css  js  c++  java
  • 一些mysql innodb的建议

    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选项
     
     
  • 相关阅读:
    一个JavaScript反射使用的例子
    JQuery中的each()的使用
    WebHome < Visualization < Virtual Test Facility
    UsageHdf < Amroc < Virtual Test Facility
    批量去除输出数据文件名前面的"output“
    官网EI数据库更新
    NASA CEA 安装指南
    FORTRAN学习网站
    Ubuntu下批量使用Tecplot的preplot命令对数据进行处理
    FORTRAN和C语言数组循环顺序
  • 原文地址:https://www.cnblogs.com/charlesblc/p/6669844.html
Copyright © 2011-2022 走看看