Question

I am using mariadb 10.4 with nignx with joomla 4 on Debian 8 system.

Is it possible for a table that is already created with records in a working database to be moved on memory?

I find only tutorial to create the table from scratch not for changing it after it is created.

Is it possible to have some records on the disk and the rest on the memory?

Was it helpful?

Solution

Yes:

ALTER TABLE the_table ENGINE=MEMORY;

That said, I must strongly advice against doing this because the contents of memory tables are lost once the MariaDB server is shut down.

InnoDB is perfect for having some rows in memory and some on disk: It will put as much into memory as it can, and if there isn't enough memory for all of them, then it will only keep those that are accessed the most frequently. Also, it will persist the data to disk so that it's not lost when the MariaDB server is shut down.

OTHER TIPS

One of the ways to create a table is:

CREATE TABLE tempTable ENGINE=MEMORY SELECT * FROM myTable

This will create a new table named tempTable which has the same definition as myTable (see: https://dev.mysql.com/doc/refman/8.0/en/memory-storage-engine.html )

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top