Answer the question
In order to leave comments, you need to log in
Do DBMSs save hard disk space compared to storing (small) data in json files?
If we store a small dictionary in the settings.json file, then by loading it into memory and changing one of the values in it, we must overwrite the entire file in order to save the changes. If we have a settings table in the database and change one row in it, will only that row or the entire table be physically overwritten? when using:
1.1) sqlite
1.2) Postgresql
Answer the question
In order to leave comments, you need to log in
we have to overwrite the entire fileIf you look from this side, then yes, both JSON and XML are absolutely stupid formats when it comes to storing data in the process of processing it - it is worth changing one field, and you need to rewrite the entire tail of the file, since all records are of variable length.
If we have a settings table in the database and change one row in it, will only that row or the entire table be physically overwritten?
It all depends on the size of this file, and most importantly, do you need atomic transactions (this is necessary for multi-user write and read access), since when using them, the overhead of writing to the database increases SIGNIFICANTLY, and possibly up to 4-8 kilobytes (1 filesystem extent) it is more efficient to store and overwrite the file in its pure form without a database (although you will have to monitor the locks yourself).
If you have only reading, then without any options, work with your file (not necessarily json, it is more interesting to store it as a php code, to save data in this form, use var_dump/var_export, this is the fastest and most efficient in terms of CPU load). even a hundred kilobytes in its file can be more efficient than storing dictionaries in the database, especially since it will be perfectly cached at the OS level.
The inconvenience of storing dictionaries in a file is not a uniform method of working with data, if part of the data is in your database and part is in files, you will have to support both methods and not just one.
Taking into account the fact that the warranty on disks is now three years, the question does not make sense. That and that case will not have time to work out the server resource
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question