Performance of WordPress Plugin is currently very bad and needs to be improved
If you don't need to worry about WordPress filters on getting post meta, you probably can just do this with a single SQL statement and iterate through the results, rather than relying on WordPress to get the values from the database, since that's 20,000 sql statements, plus the memory of caching all that data (which WordPress does behind the scenes when you get post meta for a post).