15.9 seconds to 391.9 seconds. That's half your time right there. The fact that it's ending up with 242 million rows isn't promising - are you sure the query is doing what you think it is?
I am not. I can't see how materialize can multiply number of rows it gets from sort by 100.