简体   繁体   English

在MySQL中使用ENGINE作为MRG_MYISAM有什么优势

[英]Is there any advantage of using ENGINE as MRG_MYISAM in mysql

I am doing a tracking site like google adwords. 我正在做一个像google adwords这样的跟踪网站。 I am doing only modifications. 我只做修改。 In that site i have seen they are creating tables for each month and merging that table into one this is done for the tables which stores information about clicks and search details and the merged tables having crores of records.And for querying they have used only the merged table which is having crores of records. 在那个站点中,我看到他们正在为每个月创建表,并将该表合并为一个表,该表存储了有关点击和搜索详细信息的信息以及合并后的表(具有记录的部分)。在查询中,他们仅使用了合并表,其中包含大量记录。 Is there any advantage of using tables like this?And the query is taking more than 10 minutes to execute. 使用这样的表有什么好处吗?查询要花10多分钟才能执行。

Advantages are as follows, If you dont get the following advantages then do not use it. 优点如下:如果您没有获得以下优点,请不要使用它。

Easily manage a set of log tables. 轻松管理一组日志表。 For example, you can put data from different months into separate tables, compress some of them with myisampack, and then create a MERGE table to use them as one. 例如,您可以将不同月份的数据放入单独的表中,使用myisampack压缩其中的一些数据,然后创建MERGE表以将它们用作一个表。

Obtain more speed. 获得更高的速度。 You can split a large read-only table based on some criteria, and then put individual tables on different disks. 您可以根据某些条件拆分一个大型只读表,然后将各个表放在不同的磁盘上。 A MERGE table structured this way could be much faster than using a single large table. 以这种方式构造的MERGE表可能比使用单个大型表快得多。

Perform more efficient searches. 执行更有效的搜索。 If you know exactly what you are looking for, you can search in just one of the underlying tables for some queries and use a MERGE table for others. 如果您确切知道要查找的内容,则可以仅在基础表之一中搜索某些查询,而在其他表中使用MERGE表。 You can even have many different MERGE tables that use overlapping sets of tables. 您甚至可以拥有许多使用重叠表集的不同MERGE表。

Perform more efficient repairs. 执行更有效的维修。 It is easier to repair individual smaller tables that are mapped to a MERGE table than to repair a single large table. 修复映射到MERGE表的单个较小的表比修复单个大型表要容易。

Instantly map many tables as one. 立即将多个表映射为一个。 A MERGE table need not maintain an index of its own because it uses the indexes of the individual tables. MERGE表不需要维护其自身的索引,因为它使用各个表的索引。 As a result, MERGE table collections are very fast to create or remap. 因此,MERGE表集合可以非常快速地创建或重新映射。 (You must still specify the index definitions when you create a MERGE table, even though no indexes are created.) (即使没有创建索引,在创建MERGE表时仍必须指定索引定义。)

If you have a set of tables from which you create a large table on demand, you can instead create a MERGE table from them on demand. 如果您有一组表,可以根据需要从中创建一个大表,则可以根据需要从中创建一个MERGE表。 This is much faster and saves a lot of disk space. 这快得多,并节省了大量磁盘空间。

Exceed the file size limit for the operating system. 超出了操作系统的文件大小限制。 Each MyISAM table is bound by this limit, but a collection of MyISAM tables is not. 每个MyISAM表都受此限制约束,但没有MyISAM表的集合。

You can create an alias or synonym for a MyISAM table by defining a MERGE table that maps to that single table. 您可以通过定义映射到单个表的MERGE表来为MyISAM表创建别名或同义词。 There should be no really notable performance impact from doing this (only a couple of indirect calls and memcpy() calls for each read). 这样做不会对性能造成任何明显的影响(每次读取仅需要进行两次间接调用和memcpy()调用)。

You can read more about this on basic info link , advantages disadvantages link . 您可以在基本信息链接优点和缺点链接上阅读有关此内容的更多信息

A MRG_MYISAM only works over MyISAM tables, which are, by themselves, not the first option for a table. MRG_MYISAM仅适用于MyISAM表,这些表本身并不是表的首选。 You would normally go for InnoDB tables. 您通常会使用InnoDB表。

The MRG_MYISAM engine was invented before MySQL had support for views and for partitions. MRG_MYISAM引擎是在MySQL支持视图和分区之前发明的。 Range partitioning (eg partition per month) is most probably what you want. 范围分区(例如每月分区)很可能是您想要的。

Partitioning is transparent to the user in terms of queries, but nevertheless uses pruning so as to only read from selected partitions for a query, thus optimizing it. 分区对用户而言对查询是透明的,但仍使用修剪功能,以便仅从所选分区中读取查询,从而对其进行优化。

I would recomment that you use InnoDB tables, and check out range partitioning . 我建议您使用InnoDB表,并检查范围分区 MRG_MYISAM and MyISAM are still in use. MRG_MYISAM和MyISAM仍在使用。 They could work out for you. 他们可以为您解决。 It's just that MyISAM introduces so much trouble (no crash recovery, table level locking, more...) that it's many times out of the question. 仅仅是MyISAM引入了很多麻烦(没有崩溃恢复,表级锁定等等),以至于无数次了。

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

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