12

I have created HEAP (ram) table on mysql for faster query. But after mysql server restarted, the data in my Heap tables is not loaded.

My normal table name: products with id, product_name, status as myisam

id => integer and auto_increment, primary key

product_name => var_char and key(index)

status => boolean

Actual Query:

`Select id from products where product_name like "product_name"`

I want to increase speed, so i created table with same structure and with named products_ram as mysql HEAP table. I am using this code for fill:

insert p_shop.products_ram select * from p_shop.products;

But when restart mysql instance HEAP (ram) table data has gone.

I found a document about mysql memory storage : http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html

But i can't find what i looking for.

I want to insert/copy my data from products table to products_ram table on mysql server initialization automatically.

Any help will be appreciated.

Edit: My Operating System : Windows Server 2008 R2 And Mysql : MySQL 5.5

trincot
  • 317,000
  • 35
  • 244
  • 286
EngineerCoder
  • 1,445
  • 15
  • 30

1 Answers1

11

The init_file server option lets you define arbitrary SQL statements to be executed on startup.


Edit: Changed the link as the resource has moved on the target site.

Community
  • 1
  • 1
RandomSeed
  • 29,301
  • 6
  • 52
  • 87
  • 5
    yep, my.ini file located `C:\Program Files\MySQL\MySQL Server 5.1\my.ini`, I added this line under the `[mysqld]` `init-file="C:/inetpub/wwwroot/start.sql"` and it works! Thank you. – EngineerCoder Dec 23 '14 at 07:51
  • As I am running on a windows machine as well I had to be aware that the path given in the file must be written with _forward-slashes_ not back-slashes. – Bjarne Nov 11 '19 at 11:56
  • Updated link for MySQL 8.0: https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_init_file – Roger Dueck Nov 29 '19 at 15:19