Simple query with JOIN on 60M rows using index takes forever in MariaDB/MySQL
Adding an index to data_sources(source_id, log_time) solved the problem.

create index index_data_sources_source_id_log_time on data_sources(source_id, log_time);


This brought the execution time down to a couple of seconds.

Apparently the calculation of interval sources.retention_days day &lt; current_timestamp doesn't have such a massive performance impact, as I suspected.

Thanks for the helpful comments!