Should I compress files to save to the database?

Asked

Viewed 375 times

4

I don’t want to take into account whether saving files in the database is a good practice.

Since many systems save the files (images, pdf’s, doc’s, etc.) in the database, I would like to know if it is a good practice to compress these files by zipping them, for example.

The size of the bank can have great influence on the system, whether by limitations, memory bottlenecks, etc. With this, it pays to reduce the size of the files because you will have a job to compress whenever you save the file and unzip whenever you show the same file to the user?

  • I did not understand very well what you meant by "influence on the system" and "memory bottlenecks", as far as I know the physical size of Cords (lines) in the bank matters little near the amount Records/lines, except if you are doing something like index them or if you are worried about exceeding the limit allowed by your RDBMS.

  • @Brunorb I guess I didn’t put it very well. The size of the bank can influence the development and tools that will be used for development, as well as basic maintenance in case of any problems. Today we don’t care much about memory when developing small systems, but there are systems that there are various memory overload problems. There are people who don’t even know what GC would be and what it’s for.

2 answers

2


Since many systems save the files (images, pdf’s, doc’s, etc.) in the database, I would like to know if it is a good practice to compress these files by zipping them, for example.

Yes, and quite common, by the way. One of the most famous for this, by the way, is the Zlib.

Compensates to reduce the size of the files in view that will have a job to compress whenever it is to save the file and unzip whenever it is to show this same file to the user?

Unless your system is mission-critical, and thousands of requests are made to download gigantic files (I’m talking hundreds of megabytes here), it’s worth it yes.

According to the author of Zlib himself (see also the question asked), there are still ways to accelerate compression and decompression using faster methods, but with a lower compression quality. Then it’s worth it to run tests on the various compression libraries and their options to determine what best meets your need.

  • At the end of the last sentence, it would be "to determine what answers..."?

  • @Diegof Yes. Thank you.

2

It depends on how often you will want to access these files. If they’re gonna be out there mowing most of the time, and assuming you don’t have or can’t get more disk space, maybe it’s worth it. Now if you will be accessing them constantly is not very smart to have to decompress at each access, will end up degrading their performance in exchange for saving physical memory.

An exact answer will depend a lot on your situation, but overall I would not recommend, spending on disk space is in most cases much less relevant than spent on processor/ram.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.