I can't seem to find out if this is implemented in mysql? I can only find information relating to postgresql.
So, can you use JSONB in mysql or is it just JSON?
The JSONB data type stores JSON (JavaScript Object Notation) data as a binary representation of the JSONB value, which eliminates whitespace, duplicate keys, and key ordering. JSONB supports GIN indexes.
JSON has been supported by MySQL since version 5.7. 8. MySQL stores JSON in binary form, like PostgreSQL's JSONB format. This means that the JSON is always validated, because it's always parsed, and it's efficiently accessed as it's optimized into keys with values and arrays.
Note that any database will accept JSON documents as a single string blob. However, MySQL and PostgreSQL support validated JSON data in real key/value pairs rather than a basic string.
The main difference between the json
and jsonb
types in Postgres is that the latter is stored in a compressed binary format. From the MySQL documentation, it appears that MySQL's JSON type already has at least some of the behavior of Postgres' jsonb
:
The JSON data type provides these advantages over storing JSON-format strings in a string column:
Optimized storage format. JSON documents stored in JSON columns are converted to an internal format that permits quick read access to document elements. When the server later must read a JSON value stored in this binary format, the value need not be parsed from a text representation. The binary format is structured to enable the server to look up subobjects or nested values directly by key or array index without reading all values before or after them in the document.
If I recall correctly, the MySQL JSON functions will still work correctly on JSON text (e.g. stored as varchar
), so maybe MySQL's analogy to Postgres' json
would just be storing JSON content as plain text.
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