mysql memory storage engine

8
MySQL 5.6 Memory Kristian Köhntopp

Upload: kristian-koehntopp

Post on 15-Jan-2017

466 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: MySQL Memory Storage Engine

MySQL 5.6 MemoryKristian Köhntopp

Page 2: MySQL Memory Storage Engine

Memory

• .frm file on disk, data in memory

• table locks

• Hash Index, BTree available

• CREATE TABLE t ( id INT, INDEX USING BTREE(id)) ENGINE = MEMORY;

2

Page 3: MySQL Memory Storage Engine

Limits

• Fixed Length Row Storage

• VARCHAR silently becomes CHAR

• c VARCHAR(255) CHARSET utf-8

• There are no TEXT and BLOB types

3

Page 4: MySQL Memory Storage Engine

Limits

• max_heap_table_size = 16M

• Memory tables do not shrink by DELETE

• ALTER TABLE m ENGINE=memory

4

Page 5: MySQL Memory Storage Engine

Empty after restart

• .frm file persists, so MEMORY tables do not go away

• Data does not persist

• --init-file=autostart.sql

• insert into memory select * from disk

• Replication?!? Fake DELETE!

5

Page 6: MySQL Memory Storage Engine

Temporary Tables

• 'using temporary' in EXPLAIN:

• Implicit temporary tables

• subject to storage conversion

• > max_heap_table OR > tmp_table_size OR not possible in MEMORY:

• converted to MyISAM!

6

Page 7: MySQL Memory Storage Engine

Temporary Tables

• SHOW GLOBAL STATUS LIKE ‘Created_tmp_%tables’; • Created_tmp_disk_tables =2566203

• Created_tmp_tables =4914265

• 2566203/4914265*100 = 52.2195% go to disk

• > 10% → too many → check SQL!

• Created_tmp_disk_tables per second (<10 → ignore)

7

Page 8: MySQL Memory Storage Engine

Temporary Tables

• Disk Accesses are slow.

• We do not want conversion!

• tmp_table_size == max_heap_table_size

• No TEXT or BLOB in queries with 'using temporary'

• Check out the sizes of your VARCHARs in MEMORY

8