How to Optimize WP site for millions of posts

I’m working on a website for a company that will very likely be creating millions of posts via a custom post type. They’re prayers, so basically the user on the front end just submits a short phrase via a form. All the company cares about is the post content and the date posted. The site hasn’t even launched yet and they already have over 120,000 posts, so I’m dead serious when I say millions.

Retrieving and Displaying Data From a Table

At the moment, I have created a code that retrieves data from the database and displays it. However, for some reason, I cannot see the files I want to retrieve on my page. My goal is that the data gets retrieved from the database, and is displayed on the webpage. I do not need to make a connection with the database since WordPress does that automatically.