JSON_STORAGE_FREE() – Find Out How Much Storage Space was Freed Up After an Update of a JSON Document in MySQL

In MySQL, the JSON_STORAGE_FREE() function shows how much storage space was freed up after a JSON Document was updated.

For a JSON column value, it shows how much storage space was freed in its binary representation after it was updated in place using JSON_SET(), JSON_REPLACE(), or JSON_REMOVE().

For a JSON document (or a string which can be parsed as one), this function returns 0.

Continue reading

JSON_STORAGE_SIZE() – Find the Storage Size of a JSON Document in MySQL

In MySQL, the JSON_STORAGE_SIZE() function returns the number of bytes used to store the binary representation of a JSON document.

You provide the JSON document as an argument.

When the argument is a JSON column, this function returns the space used to store the JSON document as it was inserted into the column, prior to any partial updates that may have been performed on it afterwards.

When the argument is a string, the function returns the amount of storage space in the JSON binary representation that is created by parsing the string as JSON and converting it to binary.

Continue reading

JSON_SEARCH() – Find the Path to a String in a JSON Document in MySQL

In MySQL, the JSON_SEARCH() function returns the path to a given string in a JSON document.

You provide the JSON document as an argument to the function. You also provide the argument that determines the actual string to search (including any escape characters), as well as a keyword to indicate whether to return the path of all instances or just one.

Continue reading

JSON_KEYS() – Return the Keys from a JSON Object in MySQL

In MySQL, the JSON_KEYS() function returns keys from the top level value of a JSON object. The keys are returned as a JSON array, or, if a path argument is given, the top-level keys from the selected path.

You provide the JSON document as an argument to the function.

You can also (optionally) provide a second argument to specify where the “top-level” path starts from within the JSON document.

Continue reading