2

As I experienced, Blob type is good choice when you want to save binary data such as images or videos etc and Text type is good choice when you want to save large string.

Today I saw Wikipedia database. The interesting thing was that wiki use medium blob type for storing wikitext of the page.

enter image description here

So I want to know why Wiki prefer to use Blob type instead of Text?

Thanks

2 Answers 2

5

The 'right' way to store text is to use TEXT with CHARACTER SET ut8fmb4. However, that requires the you know what encoding exists in the client, so that it can be converted (by MySQL) as it is stored.

By storing into BLOB, the above issue is eliminated. However, that leads to another issue -- how to display the text.

Another possible excuse for BLOB is that Wikipedia was probably started before utf8mb4 was added to MySQL.

(We can only guess.)

1
  • > The 'right' way to store text is to use TEXT with CHARACTER SET ut8fmb4 This not entirely true- aside from the fact we started using it before utf8mb4 was a thing, Wikipedia support of encodings/collations is more bleeding edge than MySQL adopting them (to the point that in some cases our community is the one implementing the collations). Also, there is not way to do per-row collation, so we have to implement that at app level. It is true that most applications would be fine with just using utf8mb4.
    – jynus
    Jul 26, 2018 at 15:01
3

Might be in order to avoid undesired changes when storing the data, due to encoding issues.

Any encoding has its supported character set. When you store text in a specific encoding some of the characters might be translated in order to fit the storage character set.

BLOB is stored "as is" while text content is being manipulated according to the encoding being used.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.