Write a function to merge two large datasets on a non-unique key and optimize the memory footprint of the resulting DataFrame.