Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is better: Parsing big data each time from the DB or caching the result?

I have a problem regarding the system performance. In the DB table there will be a big XML data in every record. My concern is that if I should parse the XML data each time from the DB to get the attributes and information in the XML. The other choice could be parsing the XML once and catching them. The XML size averages 100KB and there will be 10^10 records. How to solve this space vs computing performance problem? My guess is to catch the result(important attributes in the XML). Because parsing 10^10 records per query is not a easy task. Plus the parsed attributes can be used as the index.

like image 337
Marcus Thornton Avatar asked Nov 28 '25 03:11

Marcus Thornton


1 Answers

If you are going to parse it all every query you undoubtly should cache the results, perhaps put the full generated product into a single database field or a file for future use, or at last until something is changed, just like a forum system do.

Repeating an expensive process on a massive amount of data knowing you will always get the same result is a real waste of resources.

like image 91
Havenard Avatar answered Nov 30 '25 16:11

Havenard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!