A method, computer system, and computer program are claimed for selecting
rows from first and second tables each having rows containing values in
columns. In at least the first table, the rows are divided into partitions
at least one of which is populated by one or more rows. The method,
computer system, and computer program include (a) defining a subset of the
populated partitions of the first table that excludes at least one
populated partition of the first table, (b) creating a file context, which
stores at least location data for a row and a first value associated with
the row, for each populated partition in the subset of the populated
partitions of the first table, (c) determining the lowest first value
stored by the file contexts for the first table, (d) identifying rows with
a particular first value by at least reading the file contexts of the
first table, and (e) repeating a through d until the subsets of the
populated partitions of the first table have included all the populated
partitions of the first table.