Mysql – Best way to store few rows of data every minute without creating 1440 columns a day

MySQLoptimizationperformancequery-performance

I will be calling a server that returns some JSON data every minute. The values are along the lines of Value, Currency, DateTime, and maybe 1 or 2 more values.

What is the best way to keep save these related values in a table using MySQL?

  • 1440 columns with one column per minute and 1 row per day?
  • 1440 rows with 4 or 5 columns? One row with 1 column as a text/blob with the 1440 minutes of data as a serialized array?

I feel like that last one might be best since it's only one days worth of data and it can be queried by day. I'm just afraid of how large that text column might get and if someone wants to see a years worth of rows, how long would it take to retrieve, unserialize, and return 1440 X 365 worth of arrays. I'm by no means a database admin, so this isn't something I've ever encountered.

Best Answer

I would argue for 1 row per data event (so 1440 rows per day) with one static column per data point. This will be easiest to query against any of the fields.