简体   繁体   English

MySQL性能:许多行和列(MyISAM)

[英]MySQL performance: many rows and columns (MyISAM)

Since I'm still in the beginning of my site design I figured now's a good time to ask this. 由于我还在我的网站设计的开头,我觉得现在是问这个问题的好时机。

I know that one of the ways to optimize MySQL queries is to split your rows into seperate tables, however, that does have a few comfort issues. 我知道优化MySQL查询的方法之一是将行拆分为单独的表,但是,这确实有一些安慰问题。

What I'm considering is this: would querying a table consisting of around 1'000'000 rows and 150 columns using excellently designed indexes and getting only the needed columns from each query result in a much higher server load than splittiing the table into multiple ones, resulting in less collumns? 我正在考虑是这样的:将查询由周围的表1'000'000行和150用出色的设计指标,只获得了需要的列从每个查询的结果高得多的服务器负载比splittiing表为多列那些,导致较少的柱子?

Big blob tables are a anti-pattern, never use them. 大blob表是一种反模式,从不使用它们。

Normalized tables will run much much faster than a single blob. 规范化表的运行速度比单个blob快得多。
InnoDB is optimized for many small tables that need to be joined. InnoDB针对需要连接的许多小型表进行了优化。

Using a normalized table will save you many headaches besides: 使用标准化表将为您节省许多麻烦,除了:

  1. Your data will be smaller, so more of it fits in memory. 您的数据会更小,因此更多的数据适合内存。
  2. You only store data in one place, so it cannot end up with inconsistent data. 您只将数据存储在一个地方,因此不会以不一致的数据结束。
  3. MySQL only allows you to use one index per select per table, multiple tables means you get to use more indexes and get more speed. MySQL只允许每个表每个选择使用一个索引,多个表意味着您可以使用更多索引并获得更快的速度。
  4. Triggers on tables execute much faster. 表上的触发器执行得更快。
  5. Normalized tables are easier to maintain. 规范化表更易于维护。
  6. You have less indexes per table, so inserts are faster. 每个表的索引较少,因此插入更快。
  7. Indexes are smaller (fewer rows) and narrows (less columns) and will run much faster as a result. 索引较小(较少行)和较窄(较少列),因此运行速度更快。

If the data is static, you can pack the tables for greater efficiency. 如果数据是静态的,您可以打包表以提高效率。 Here is the page in the reference manual 这是参考手册中页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM