I have to write a program that compares 10'000'000+ Entities against one another. The entities are basically flat rows in a database/csv file. 

The comparison algorithm has to be pretty flexible, it's based on a rule engine where the end user enters rules and each entity is matched against every other entity. 

I'm thinking about how I could possibly split this task into smaller workloads but I haven't found anything yet. Since the rules are entered by the end user pre-sorting the DataSet seems impossible. 

What I'm trying to do now is fit the entire DataSet in memory and process each item. But that's not highly efficient and requires approx. 20 GB of memory (compressed). 

Do you have an idea how I could split the workload or reduce it's size? 

Thanks