in reply to PSQL and many queries
Do it the COBOL way:
It is possible to perform this operation (of course, without writing any new code to do so yourself...) by processing the two files sequentially. No searching is required. “10 million records?” No problem!
(If you ever watched old sci-fi movies and wondered “what all those spinning tapes were doing” ... now you know.)