For some context, I'm writing software to index blockchain data for a dApp I'm creating. It basically uses ETH RPC calls to get eth logs, parses them, inserts into a DB, and updates checkpoints.
I use eth_logs to get logs for past blocks, and it works fairly quickly. However, I need to get the timestamp associated with each piece of data. Since eth_logs doesn't return any timestamp, I find myself calling eth_getblock and getting the timestamp from that. This is extremely, extremely slow (like 50x + slower once adding this). It's very inefficient cause you basically have to get every single block; eth_getblock returns transactions and everything. It doesn't seem reasonable to have an indexer running for days longer just to get timestamps.
Is there any more efficient way of getting timestamps associated with eth logs that anyone is using? One solution is to maintain a proprietary DB that has a mapping from block number to timestamp, that way you only have to index everything once and can reuse it. However it doesn't seem reasonable for everyone who needs this functionality to maintain their own DB. Wondering if others have ran into this inefficiency, and gotten around it.