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

  |   本站Feed      

Memory存储引擎表大小限制

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

表大小受控制。

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

测试:

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

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

1、创建类型的表

mysql> create table test_memory 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)

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

表大小查询sql:
http://www.mysqlperformanceblog.com/2008/03/17/researching-your-mysql-table-sizes/

IT技术博客大学习

↑ 分享IT博客大学习的文章

相关文章

Leave a Reply