1

Given you have a JSON column called slug structured like this:

{
    "en_US": "slug",
    "nl_NL": "nl/different-slug"
}

This could be indexed by adding generated columns to the table that point to the values of en_US and nl_NL. This works fine but adding a third locale would require a table schema update.

Would it be possible to let MySQL automagicly index all the key value pairs in the JSON without explicitly defining them in the schema?

2
  • How would you use those indices? Commented Aug 12, 2018 at 16:46
  • To speed up querying against a slug Commented Aug 12, 2018 at 17:31

1 Answer 1

1

As mysql manual on json data type says:

JSON columns, like columns of other binary types, are not indexed directly; instead, you can create an index on a generated column that extracts a scalar value from the JSON column. See Indexing a Generated Column to Provide a JSON Column Index, for a detailed example.

So, the answer is no, mysql cannot index the contents of a json column automatically. You need to define and index generated columns.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.