Answer the question
In order to leave comments, you need to log in
How much RAM is needed for mysql with a table size of 2gb?
There is a database for the site. It has one table - 5 million rows, 2GB size.
Initially, it was all spinning on vps with 1GB of memory. Then I began to refine the functionality, and realized that any change in the table schema or heavy queries would hang the database tightly
. Now I changed the server to 4GB of RAM and 2 cpu.
I understand correctly that in order for everything to spin quickly, it is necessary that the table fit into the RAM with a margin?
Or do you need to tweak something in the mysql settings?
mysql 5.7.22 innodb table
Answer the question
In order to leave comments, you need to log in
It will not be possible to give an unequivocal answer how much RAM is needed.
Because it all depends on how you work with the data.
Do you have a large number of non-limited samples?
Perhaps you need to refactor the code:
- limit the selection by the number of records
- limit the selection to only the necessary data
- add caching
Here it is important that indexes fit into memory. Well, the MySQL settings must be set so that there is enough allocated memory for them. It would also be nice to have an SSD if there are not enough writes: performance takes off with it.
I understand correctly that in order for everything to spin quickly, it is necessary that the table fit into the RAM with a margin?
I understand correctly that in order for everything to spin quickly, it is necessary that the table fit into the RAM with a margin?
Or do you need to tweak something in the mysql settings?
adding RAM will definitely help with SELECT queries. But it’s not enough to add a RAM, you also need to edit the mysql config so that this RAM can, in principle, be used, it won’t be right away by default.
In the case of a change in the scheme, everything usually rests on the disk. Because all operations with the database must occur atomically (that is, they must either be performed completely or not performed at all). If the power is turned off in the middle of the process or someone kills the process without waiting, the tables should be saved as they were before the change.
This is a very complex process, and as I said, it rests more on the disk. Replacing hdd with ssd will help.
You can make a copy of the database (or only one desired table) and change the schema, then rename it. But if the record goes to the database, then it just won't work either.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question