Below you will find pages that utilize the taxonomy term “MySQL”
Tune your SQL for performance
How to query JSON in MySQL with JSON_CONTAINS
You can query a JSON document in MySQL to find content within it with:
- The
JSON_CONTAINS
function that will return if a JSON document is contained within another JSON document. The function returns1
if the document is contained,0
elsewhere. - The
JSON_CONTAINS
function that will return if a JSON document path is contained within another JSON document. The function returns1
if the document is contained,0
elsewhere.
How to CONCAT in MySQL
One of the most common tasks with strings is concatenation! This blog post showcases several techniques to perform it with MySQL.
1 billion rows challenge in MySQL
Earlier this month I wrote a piece on solving Gunnar Morling interesting 1 billion rows challenge in PostgreSQL and ClickHouse. Since Aiven provides also MySQL, I wanted to give it a try. TLDR; The results are much slower than PG and ClickHouse, do you have any suggestion on how to improve?
How to tabulate a JSON document in MySQL
You can tabulate a JSON document (retrieve it as a row) in MySQL with the JSON_TABLE
function.
How to remove a field in a JSON document in MySQL
You can remove a field from JSON document in MySQL with the JSON_REMOVE
function.
How to insert a field in a JSON document in MySQL
You can insert a field in a JSON document in MySQL with the JSON_INSERT
function.
How to edit a JSON document in MySQL
You can edit a JSON document in MySQL with:
- The
JSON_SET
function that will replace values for JSON paths that exists and add values for the ones that don’t exist. - The
JSON_REPLACE
function that will replace values for JSON paths that exists and ignore the ones that don’t exist.
How to merge JSON documents in MySQL
You can merge two JSON documents in MySQL with:
- the
JSON_MERGE_PRESERVE
function to concatenate the document values - the
JSON_MERGE_PATCH
function to keep the latest value for each key
How to create a JSON document from fields in MySQL
You can create a JSON document from fields in Mysql® with the JSON_OBJECT
function
How to get the JSON field types in MySQL
To get the type of a JSON item in MySQL you need to use the JSON_TYPE
function.
How to extract an item from an array in a JSON object in MySQL
To extract an item from an array in MySQL you need to use the ->
operator and the [item_number]
JSON Path Syntax.
How to extract a field from a JSON object in MySQL
MySQL® offers three ways to extract fields from a JSON object:
- the
->
operator to extract the field as JSON - the
->>
operator to extract the field as text - the
JSON_EXTRACT
function
Both operators use the JSON Path Syntax
How to load JSON data in MySQL?
To load JSON data into a MySQL column you need to include it as string.
How to JSON in MySQL
This series covers how to solve common problems on JSON datasets with MySQL and it includes (links will appear once the target pages are up):