Merging a bunch of tables: Algorithm suggestions?

Merging big tables sucks.
Or something like that.
My table merge code currently works as follows:
- Load up a whole bunch of sorted partial tables
- Memory map them (64-bit OS required, not even screwing with 32-bit boxes here)
- Go through the "top" element of each list, grab the minimum, stick it in the output stream.
This is a really bad algorithm, as it scales with O(L*N) where L is the length and N is the number of table parts being merged. Merging a lot of tables sucks.
Anyway, suggestions on a better way to do this?
Or something like that.
My table merge code currently works as follows:
- Load up a whole bunch of sorted partial tables
- Memory map them (64-bit OS required, not even screwing with 32-bit boxes here)
- Go through the "top" element of each list, grab the minimum, stick it in the output stream.
This is a really bad algorithm, as it scales with O(L*N) where L is the length and N is the number of table parts being merged. Merging a lot of tables sucks.
Anyway, suggestions on a better way to do this?