When to refresh data?

I've got a web application where the data is constantly changing. But when to refresh it?

There is a filtering tool (a sunburst chart) and a table that displays the data. So when the user selects a filter the data that shows in the table might be invalid the next second. But what is the best way to handle this?

Is it better to refresh the data every second, without the user having to do any action, or is it better to refresh it when the user actually performs an action? It would probably be annoying when the data in the table keeps updating all the time, but on the other hand, the user might viewing invalid data.

If it is better with having to perform an action, what action? An intentional action or not? Like, if the the user uses the filtering tool and the data in the table (and the look of the filtering tool) will change. Will this confuse the user? Would the best practice be to have a refresh button and let the user have control over when the data will be refreshed. But the problem still stand on the invalid data. What would the best practice be?