A lil background info
At the moment I have a script that parses a page on a site (not controlled by me) into a mysql database for a game (Getting ingame attack logs). I’ve recently decided I wanted to upgrade this faster and I’ve completely recoded the parser so that it stores the data into an array. Now onto the basis of my question:
My first version currently has around 50 columns, one for each unit times by how many a user lost/has left and a few other bits and pieces – these often go unused if the user doesn’t actually lose a unit or doesn’t loose a unit of that type. Now if I was to JSON encode the array and literally stick that into the database
1) will that be faster than the current one when inserting?
2) Lets say I need to get that data back on the front page and show 100 results(Only a summary is needed so only 3 columns selected on the first way), if I was to do the first way I could show the data with one select and while loop it, would that be slower or faster than me selecting it from the db, then decoding it and processing it?
(Also if you know of a better way, don’t hesitate to say 🙂 – or if I should do a mix of the two)
The issue isn’t so much with the inserting, which you only do once per record – but in the reading. You will lose of all MySQLs data-processing powers as you will just have a JSON lump sat in a big text field.
It would be much more performant to be able to select the records you need from the database using a MySQL query than it would be getting all records from the database and looping around them in memory.