The Nasdaq Composite has rallied over the last month following its worst start to the year in decades. While no one knows what comes next in 2022, it can be said with some certainty that owning growing companies for many years leads to wealth-building gains. What better way to set a solid foundation for retirement than to own shares of some of the fastest-growing companies in the market?

Advertising platform provider The Trade Desk (TTD -0.54%) and database leader MongoDB (MDB -0.86%) are experiencing strong demand for their services right now. Here's why these two stocks are solid picks to ride out the storm.

1. The Trade Desk

The shift to digital advertising is a ripe field to seek out growth stocks, but it's such a wide-open market you have to know where to look. The sweet spot right now is connected TV, which is expected to see ad spending more than double to $38 billion by 2026, according to Statista. Brands and content owners are increasingly allocating resources to connected TV platforms instead of Alphabet's Google. 

Google has dominated the search advertising market for a long time, but some companies don't trust Alphabet with their data, especially given allegations of Google's antitrust behavior. The emergence of connected-TV platforms is changing the playing field, allowing advertisers more competition-friendly options to display ads besides relying on Google search. This shift is already driving tremendous growth for The Trade Desk, a leading digital ad management platform.

Shares of The Trade Desk have soared over 1,000% over the last five years, but there are potentially more gains to come for patient investors. In the second quarter, the company posted revenue growth of 35% year over year. That brings its trailing-12-month revenue to $1.4 billion, but The Trade Desk has a much larger opportunity ahead. 

It's benefiting from a growing digital ad market, but it's also gaining market share. Google reported advertising growth of just 11.5% year over year in the last quarter. The Trade Desk is signing new partnerships with businesses at a record rate across several industries. 

A major growth catalyst to watch in the near term is the launch of ad-supported streaming services. The Trade Desk is working with Walt Disney to automate ad impressions across the entertainment leader's portfolio of brands. With Disney+ counting 152 million subscribers and still growing, this partnership is a huge win for The Trade Desk. Management believes an eventual partnership with Netflix, which is planning to launch an ad-supported service, is also likely. 

It's not too late to buy shares. The Trade Desk's market cap is $32 billion, which is relatively small these days, especially considering that the leading digital advertiser, Alphabet, has a market cap of $1.5 trillion. The Trade Desk could see its market cap grow to well over $100 billion over the long term as it continues to win new partnerships and gain market share.

2. MongoDB

Another fast-growing company to consider is MongoDB, a leading provider of database technology for software applications. Databases are mission-critical for companies since all software runs on data. MongoDB provides a document-based database known as NoSQL that is faster and more efficient than legacy SQL-based databases. The company offers its service through a subscription and has partnerships with large cloud service providers. 

There are many providers of NoSQL databases, but MongoDB has emerged as the favorite in this race. It has over 35,000 customers, with revenue increasing 57% year over year in the most recent quarter. The stock has returned an almost tenfold gain to investors over the last five years, bringing MongoDB's market cap to $23 billion. 

MongoDB has become the most in-demand database solution in the world. Organizations of all sizes use MongoDB, from large Fortune 500 companies to upstarts. It is so well entrenched in this market that Amazon decided to partner with MongoDB instead of competing against it. The two companies have a multi-year agreement to offer the MongoDB Atlas cloud-based database to Amazon Web Services customers. 

Amazon understands it doesn't need to invest capital to compete against the smaller company. It can simply offer MongoDB's Atlas database on AWS and leverage the popularity of Atlas to grow AWS adoption. It's a huge win for both businesses.

The global NoSQL market is expected to expand 30% per year from 2022 through 2027 to reach $27 billion, according to Imarc Group. MongoDB has been growing revenue at 40% or more since the company's initial public offering in 2017.  

The Amazon partnership is a sure sign that MongoDB has a competitive offering that should allow it to grow faster than the market. Investors are likely looking at handsome returns from the stock over the next 10 years as companies continue investing in digital services that improve operating efficiency -- in this case, software development.