0

Colleagues, tell me how to keep a copy of the table in RAM?

I have a database server on MariaDB. One of its databases contains a small table - about five fields and several dozen records. The records are not changed often - once every few hours. But, unfortunately, several dozen machines read records from this table every thirty seconds. (Alas, there is nothing I can do about it, I didn’t come up with it.)

Can I load a copy of this table into memory, so that information (INSERT, UPDATE, DELETE) is written to disk and memory, and when read requests (SELECT), reads come not from disk, but from a copy in memory?

Thanks in advance for the answers.

6
  • 1
    If the there is sufficient memory this should be kept in RAM. Do you have any reqson to believe its not? (This is a property of modern OS's to the extent it is not also a property of databases)
    – davidgo
    Commented Oct 24, 2021 at 5:26
  • @davidgo I completely agree that a copy of the table should be kept in its entirety in RAM. And how to set up such a mode of using this table?
    – ogogon
    Commented Oct 24, 2021 at 19:11
  • You should not need to do anything, provided your system is not RAM starved. Again, do you have reason to believe the table is not being kept in RAM? Are you using innodb or isam tables? Do you have indexes on the table?
    – davidgo
    Commented Oct 24, 2021 at 19:24
  • I am configuring a new server and am interested in this aspect. Is there a way to instruct my DBMS that a specific table should always be completely duplicated in memory?
    – ogogon
    Commented Oct 25, 2021 at 0:47
  • 1
    The OS should do this out-the-box Im not sure its possible to force this behaviour without hackery (eg a RAMDisk replicated to disk). AFAIK, memory tables are in RAM only so dont meet your persistence requirements. Setting innodb_buffer_pool_size can push MYSQL to keep more stuff in RAM. I guess a dedicated db instance for this table would, in practice, also ensure the table remain is RAM.
    – davidgo
    Commented Oct 25, 2021 at 2:02

1 Answer 1

1

As comments suggest, its best not to micro-manage a database architecture.

If these are InnoDB tables, a sufficient innodb_buffer_pool_size will mean these are always in memory after first access (without any manual intervention). Other databases engines have similar characteristics.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .