Recently when investigating a very slow database backup operation, I had to spend some time deciding which command to use: gzip or compress. My observations are below.
Background:
The Database hot backup of 350G is taking 9 hours to complete. The shortest time the previous vendor could manage a hot backup was in 4.5 hours. It fell upon me to investigate what is causing the delay in the backup of the datafiles. One of the aspects we reviewed as part of determining the cause was to decide which command should be used: gzip or compress. The command gzip shrinked the files to smaller sizes when compared to compress. However, compress took less time to shrink the file than gzip.
In the below snapshot, there are files listed along with their actual sizes and sizes they have been shrunk using compress and gzip command. Almost always gzip shrunk the files to smaller sizes than compress. Almost always, compress took less time than gzip.
The above snapshot randomly selected seven files for the test.
GZIP took 9 hours but took 50G of space for entire database
COMPRESS took 5.30 hours but took 91G of space for entire database.
Command compress takes less time to shrink files. If we have time constraints but we can do with slightly bigger compressed files, then compress is the command.
Command gzip takes more time to shrink files. If we have space constraints but we can do with slightly bigger compression times, then gzip is the command.
The observation, though, that compress is right or gzip is right cannot be made generic. One should exercise one’s own discretion when deciding which command to be used. In our case, we decided to go with compress command to save on time.