Your observation is correct, joining a file to a table results in a cartesian product by default.
Most effective solution will be loading the file in the database first and then perform a database join. You may be surprised by the perfomance improvement.