I'm saving contents of a particular div in mysql database as html elements. So the html elements content includes many elements such as:
<div id="div0" class="box" style="z-index: 2; width: 1689px; height: 1013px;">
<img style="margin: 0px; position: relative; display: block; height: 550px; width: 638px; top: 0px; left: 0px;">
</div>
Is there any way to reduce the data for efficiently storing in mysql database.
Such as any php or javascript functions to compress before saving to db.
Why compress? Disk space is cheap, and storing it in a compressed (e.g. gzip) format will just cost you CPU time to decompress/recompress each time.
As well, once you compress the data, it becomes an opaque binary blob to the DB, and you lose any ability to search that text via substring/fulltext.
You could compress the string before saving it to the database using gzcompress()/gzuncompress() PHP functions or you can do it with mysql using COMPRESS()/UNCOMPRESS() in your queries - but unless you have very much data I would not recommend this.
You win some harddisk space, but you lose a lot of transparency (search, edit, convert, migrate...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With