I need to build a table that will contain a large BLOB that will take up 98% of the row size. However, this BLOB will only be kept temporarily in the row and will be moved to another location and then the BLOB column will be set to NULL. Can MySQL reuse this space or will it always be part of the row? If it can not be automatically re-used, is there another way (say an optimize table) that I can use to manually reclaim this space? If not, I may need to find another solution for handling this particular set of data.
Share
Sounds like you will definitely be better off using Redis or even just storing your blob on the file system. This is in fact what I recommend; save the data on a file and place the filename on the table. After async upload to s3 has completed set it to null. If you are using a file system optimized to handle large objects, this will always be faster than an insert into a database.
How exactly blobs are stored depends not just on the length of the data but also on the version of mysql that you are actually using. Deleted rows can always be reused and when subsequent inserts don’t reuse the space, it can be recovered with optimize table. But optimize table will take a lock on that table. So you are slowing down the system a second time.