Answer the question
In order to leave comments, you need to log in
How to store data in database?
In general, the site has a connection to the api, and 1000 elements stretch from it. To speed up the site, I want to make sure that the connection is made once an hour, all the data is written to the database and then used from there.
Actually the question is: What is the best way to do it, write these 1000 rows to the database every time, or serialize the entire array and shove it into one cell? How it is correctly done with a minimum load on the database? Thank you!
Answer the question
In order to leave comments, you need to log in
If, besides MySQL, any K/V solution is already used, then it is better to serialize and place it there.
If only MySQL and the amount of data is small, then you can serialize (by means of the language, MsgPack, JSON, ...) into 1 BLOB type field and take it from there each time. Optionally, you can also compress with some algorithm like GZip, Deflate. But it is important to measure what is faster in the end (external API or cached data). Perhaps the game is not worth the candle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question