PosgreSQL query slow when sorting on indexed timestamp colum
The index on (cube_id, period_type) cannot be used for the ORDER BY. But it can implement the AND period_type = '1min' very efficiently.

The index on (cube_id, end_time, period_type) can be used for the ORDER BY, but cannot be used efficiently for the AND period_type = '1min'.  It can be used, just not efficiently.  It can filter the rows in the index without visiting the table, but it can't jump to a specific part of the index where it knows all of the '1min' values are located.  (The reason is that all the '1min' values within a given cube_id are not located together)

So, it has to make a choice, efficient ORDER BY or efficient period_type = '1min'.  Perhaps it is making the wrong choice, although you haven't shown evidence of that.

You should create the index (cube_id, period_type, end_time).  Then it does not have to make a choice, it gets the best of both.  It can jump to the part of the index where cube_id = 5 AND period_type = '1min', and once there then it can read the rows in order by end_time.