0

Which way has more benefit (performance, maintainability, so on) between

MySQL JSON response (final format to response to frontend)

Vs

MySQL record set and formatted to JSON in backend logic using any JSON library

JohnC
  • 209
  • 4
  • 16

1 Answers1

0

Not sure if I know what JSON response feature you are referring to unless it is driver or application specific. If you are talking about storing data as the JSON datatype then this is what I would have to say:

Will you ever have MySQL queries that reference information stored in the JSON? While the MySQL datatype does have optimized storage and extraction, any query that tries to reference contents of the JSON will add overhead to your query. Also you can't add JSON values to a table index or have other integrity constraints.

If I am making an application where there is some chunk of data that needs to stored and retrieved and I don't need to cross-reference or analyze that data at the DB level then I would go ahead and store things in the JSON format. Otherwise I would break it up into columns so I can use the DB for what it is good it.

  • Hi cody_nault, I will not storing JSON object to db. Will store using standard column based structure only. But when select the value from mysql, I'm thinking to retrieve as JSON format using MySQL JSON_Object, JSON_ARRAYAGG. But not sure, it's good idea or not. – JohnC Mar 15 '19 at 08:15
  • I did find some people discussing the use of these newer JSON Mysql features in on https://stackoverflow.com/questions/33660866/native-json-support-in-mysql-5-7-what-are-the-pros-and-cons-of-json-data-type – CodyTheCoder Mar 19 '19 at 15:55