我们致力于一个MySQL知识的分享网站

  |   本站Feed      

Memory存储引擎表大小限制

2009-07-13 21:38:19  |   才被阅读:1,948 次  |   才1条评论
分类: MySQL初级应用  |   发布: OurMySQL  |   来源:stronghearted.net
标签: ,

Memory表大小受max_heap_table_size控制。

mysql> show variables like ‘max_heap_table%’;
+———————+———-+
| Variable_name       | Value    |
+———————+———-+
| | 16777216 |
+———————+———-+
1 row in set (0.00 sec)

测试:

mysql> set max_heap_table_size = 1024;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> show variables like ‘max_heap_table%’;
+———————+——-+
| Variable_name       | Value |
+———————+——-+
| max_heap_table_size | 16384 |     –这里看来,最小只能是16384
+———————+——-+
1 row in set (0.00 sec)

1、创建memory类型的表

mysql> create table test_ engine= select * from test_last_insert_id where 1=0;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

2、查询表大小

mysql> SELECT count(*) TABLES,
    ->        sum(table_rows) rows,
    ->        sum(data_length) DATA,
    ->        sum(index_length) idx,
    ->        sum(data_length+index_length) total_size,
    ->    round(sum(index_length)/sum(data_length),2) idxfrac
    ->    FROM information_schema.TABLES
    ->    WHERE  table_name LIKE “%test_memory%”;
+——–+——+——+——+————+———+
| TABLES | rows | DATA | idx  | total_size | idxfrac |
+——–+——+——+——+————+———+
|      1 |    0 |    0 |    0 |          0 |    NULL |
+——–+——+——+——+————+———+

1 row in set (0.00 sec)

3、调用存储过程

mysql> delimiter $$
mysql> create procedure sp_insert_memory()
    -> modifies sql data
    -> begin
    -> set @x = 0;
    -> ins: loop
    ->     set @x = @x + 1;
    ->     if @x = 10000000 then
    ->     leave ins;
    ->     end if;
    -> insert into test_memory values(1,’aaaaaaaaaa’);
    -> end loop ins;
    -> end;
    -> $$
Query OK, 0 rows affected (0.00 sec)

mysql> select * from test_memory;
Empty set (0.00 sec)

mysql> call sp_insert_memory();
ERROR 1114 (HY000): The table ‘test_memory’ is full
mysql> SELECT count(*) TABLES,
    ->        sum(table_rows) rows,
    ->        sum(data_length) DATA,
    ->        sum(index_length) idx,
    ->        sum(data_length+index_length) total_size,
    ->    round(sum(index_length)/sum(data_length),2) idxfrac
    ->    FROM information_schema.TABLES
    ->    WHERE  table_name LIKE “%test_memory%”;
+——–+——+——-+——+————+———+
| TABLES | rows | DATA  | idx  | total_size | idxfrac |
+——–+——+——-+——+————+———+
|      1 |  816 | 16640 |    0 |      16640 |    0.00 |
+——–+——+——-+——+————+———+
1 row in set (0.00 sec)

总结:memory类型的表大小受max_heap_table_size参数控制

表大小查询sql:

http://www.mysqlperformanceblog.com/2008/03/17/researching-your-mysql-table-sizes/

相关文章

One Response to “Memory存储引擎表大小限制”

  1. sql wildcard,sql wildcards,sql rollback,rollback sql,sql copy table,sql sum,sql mirroring,sum sql,sql cluster,sql server performance,truncate in sql,backup sql,backup sql database,backup sql server,sql performance,date functions in sql,sql over,truncate s Says:

    sql wildcard,sql wildcards,sql rollback,rollback sql,sql copy table,sql sum,sql mirroring,sum sql,sql cluster,sql server performance,truncate in sql,backup sql,backup sql database,backup sql server,sql performance,date functions in sql,sql over,trunc…

    [...]Memory存储引擎表大小限制 | OurMySQL | 我们致力于一个MySQL知识的分享网站[...]…


Leave a Reply