I've researched about how to efficiently compute the cartesian product of two arbitrary sets, but I've found that the solutions are always quite inefficient if the size of the sets go huge. My question is, how Data base languages like MySQL do this task efficiently, is there an algorithm or a way to emulate the cartesian product in the way the Data Base languages do?.
PD: I'm using java.