Most of the times, XPATH could help you even with complex filtering of records, if you are retrieving from the database. This is advisable too. Because, filtering of records from database perspective is always efficient.
List operation filter will be handy if you want to retrieve using association because XPATH is not a possible option there.
If you do not want to use Java action, may be given the assumption that your filtering will be a progressive filtering of records, you can check if using multiple filter activity on the same list solves your problem.
The issue in this case is that I have a loop, in which each iteration of the loop I need a different subset of a larger set of objects - currently the microflow is retrieving from the database (using XPath) in each iteration of the loop, but retrieving from a database is generally an expensive operation, so my thought was to retrieve all the records once, and then filter the large list based on different criteria in each loop iteration. Perhaps I'm wrong that this would be a performance benefit, but that is what I was trying to do. This won't work even with multiple filters on the same list though, because I have to be able to filter on a range and not just a straight equals.
Indeed retrieving from the database is an expensive operation. But on the other hand, you must also think it from other perspectives.
If you have a huge dataset, then you must certainly go for pagination concepts. Because having a huge dataset in memory and processing that dataset as you mentioned, is certainly an overkill when it comes to JVM memory limitations.
Maybe then it could be more efficient to only retrieve the required dataset directly from the database.
It is always tricky to find out which best suites. But you can also use the monitoring provided and custom logging to validate which operations are costly.
Yeah, this is not likely to be a really huge dataset, but I did think about that as well. I just wanted to try both and see which would be better. But it looks like I have to continue with retrieving from the database in the loop anyway, since I can't use the filter option for my use case anyway. Thanks for your comments though, I appreciate it!