質問

I'm working at a PHP system using Yii Framework. I have a large ammount of plain text, and need to store this data on a Postgres' Database. I've made a little research and found these two functions: gzdeflate and gzcompress. I couldn't see a big difference of performance and results between these functions.

Do you guys can tell me if there is expressive difference between them? BTW, am I in the right path? Compressing plain text before putting it on the database is the best solution to save bandwidth and space on disk?

役に立ちましたか?

解決

Do not compress or otherwise encode text before putting it in the database unless you are 110% positive that you will never need to perform anything other than simple storage and retrieval on it. If you think you might ever need to issue a SELECT based on something contained in that text you're going to be completely hosed.

That said, if you plan on storing large amounts of data in a DB table many DBMSes have transparent compression built in. Eg: MySQL's InnoDB compression

Lastly, the difference between compress and deflate is negligible IMO. Just remember to never set the compression level to 9 unless you want your CPU to burst into flames for no raisin.

他のヒント

Well, between these two, gzdeflate seems to have a better compression rate. I've done some tests and didn't find a significant difference on time execution. and Yes, it always a good ideia using compression when you need to reduce space usage and band usage.

See this answer. gzdeflate does not produce the zlib header and trailer around the deflate data the gzcompress does, and so the result will always be six bytes shorter. However it then loses an important integrity check. Use gzcompress.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top