Window functions process smaller frames faster. To reduce the size of the frame, decrease the number of rows between the frame offsets, and avoid including all preceding rows or all following rows.
Use a well-distributed partition key to create partitions of similar size.