1. A method of performing a database query to join a column A and a column B on an inequality condition, the method including: determining a minimum and a maximum value for A, using a value-count index for A, the value-count index for A including which values appear in A and how many times the values appear in A; determining a minimum and a maximum value for B, using a value-count index for B, the value-count index for B including which values appear in B and how many times the values appear in B; defining three or more sets of values in A, relative to the minimum and maximum values for B; defining three or more sets of values in B, relative to the minimum and maximum values for A; generating one or more Cartesian products, where each Cartesian product is between a set of values in A and a set of values in B; performing the database query on a set of values in A and a set of values in B to generate a partial query result; merging one or more Cartesian products and the partial query result; and storing the merged one or more Cartesian products and the partial query result.