How big is the data you are talking about? If its reasonable size and still filling your storage space, then get a bigger storage space. If its huge data then you might need a whole new infrastructure.
As for optimising your code, without seeing any code, knowing anything about your process or system, or knowing anything about your data, I don't see how it is possible to provide any useful information. Why do you need to sort for instance? Can the data not be sorted up front. What about using an index? How is the sort to be used further along. How is the data stored, is it locally, network, database etc.