|Perl Monk, Perl Meditation|
Re^4: efficient perl code to count, rank (merge sort)by LanX (Sage)
|on Jul 18, 2021 at 12:36 UTC||Need Help??|
> (Well you could tie an AoA to a file representing a table. Sorting that array would go without much RAM but mean constant overhead with each access. This is certainly worth a shot, but as I said DBs have this already optimized.)
I don't think this will work because of the way merge sort is implemented in Perl
It is first comparing all pairs in a breadth first search, which would mean far too many disk operations and no sensible caching option
A caching/memoizing of data read from disk would be far more efficient if the chunks were strictly chosen depth first.
FWIW WP lists some divide-and-conquer approaches for merge-sort