Querying a large number of posts including their custom fields data

There are a number of caching plugins that may work for you, or build the data on the admin side when posts are added/updated and save it in an option.

error code: 523