2

Generating a virtual column is the recommended way to index a JSON property.

But what if the property I want to index is inside an array or object? For example, if the JSON property is an array of userIds, and I'm querying for the userId in the array so I'd want to be indexed. What would be the best approach?

Glide
  • 20,235
  • 26
  • 86
  • 135
  • What is the query that you want to use an index? How does your schema look like? – Paul Spiegel Sep 11 '16 at 15:16
  • Is this what you want to know? { "logs": [ {"userid":"1", "msg":"inserted"}, {"userid":"2", "msg":"updated"}, {"userid":"3", "msg":"updated"}, {"userid":"4", "msg":"deleted"} ] } Possible to index logs.userid ? – Jay Dubal Jun 26 '18 at 11:48
  • @JayDubal Exactly. – Glide Jun 27 '18 at 06:37
  • Please see the last answer from https://stackoverflow.com/questions/35198140/mysql-index-json-arrays-of-variable-length – Jay Dubal Jun 27 '18 at 09:18

0 Answers0