I wrote a statement that takes almost an hour to run so I am asking help so I can get to do this faster. So here we go:
I am making an inner join of two tables :
You can't really optimize your statement - it's pretty simple as it is.
What you could do is investigate if some indices would help you.
You're selecting on intervals.entry_time, intervals.exit_time, measures.time - are those columns indexed?
intervals.entry_time, intervals.exit_time, measures.time