It depends on how much data you fetch from the database.
If you need to update and process data frequently then using the database would be better since as long as you use SQL, data processing is going to be executed by the database engine and you will only fetch results (summarised data), if you don't need to update or process data frequently a file with preprocessed data would be better.