I would like to have Stockfish (or another strong engine) automatically analyze a very large database of games (>1M games), so that the analysis is as strong as possible while making the best use of my computational resources. A naive approach would be to run Stockfish on every position in every game to a certain depth, and then report the evaluation. But this would waste CPU cycles on calculating trivial positions for way too long, for example positions in which a simple recapture is obviously the only not-losing move. How should I determine how long I should let the engine think in each position?
Run a shallow search (you might want to add multi-pv). Check the magnuitude of the lines if you want to re-run a proper search. Although this sounds weird, but this is a very common strategy in Stockfish (eg: move reductions). Your won't waste your previous search because the hash-table should speed up your next search. You can read more here.
For example, you wouldn't want to waste CPU cycles in a position where white is a rook ahead.
Otherwise, I don't see a non-trivial way to detect if a position is "interesting" to search.