Basically, no - if you want a cartesian product of two sets of sizes n,m
- the size of the cartesian product is n*m
- and you need O(nm)
algorithm to generate it.
However, for data base languages, when you do things like 'join', you sometimes do not need to generate the entire join to get the answer - if all you are going to do later on is just count number of items, or sum.
This can be shown in Pig Latin's COGROUP operator, which only creates an implicit join, in order to later just use the sizes or sums - and not the real cartesian product. This potentially could be much more efficient if used properly in the right situation.