Some trends take years, even decades to play out. It was 25 years ago this month that Amazon sold its first book in its online store, but the trend of e-commerce is really just getting started. Online purchases in the U.S. are still less than 12% of overall retail sales. But investors who bought shares of Amazon at almost any point since it went public in May 1997 (and held them) have done exceedingly well.

Let's take a closer look at three stocks that are benefiting from long-term trends, and that you can buy and comfortably hold for the next 20 years: MongoDB (MDB 0.81%), DocuSign (DOCU 1.02%), and MercadoLibre (MELI -1.79%).

MongoDB: a database for the cloud-based future

Many large companies today have their key software applications running on a database architecture that was developed in the 1970s before the internet, mobile devices, or the cloud. MongoDB's database platform was built for the cloud-hosted, high-performance, mobile-ready applications of today. But upgrading your core applications and underlying database architecture is not an everyday occurrence.

Market research company IDC estimates the database market at $71 billion for 2020, but much of this spending is for products that are currently in use. Companies may take up to eight to ten years to upgrade strategic applications and the databases that power them. As these transitions happen over the next decade, MongoDB has a chance to compete for new customers with its superior technology. This market is projected to grow to $97 billion by 2023, and this new growth is likely to be driven by cloud-based applications that play to the company's advantage.

MongoDB's product is a proven winner driving incredible growth. The company's trailing-twelve-month revenues of $462 million are triple its fiscal year ending January 31, 2018 mark of $154 million. With less than a 1% share of today's market, this cloud-database specialist can be expected to grow much bigger by 2040.

Bag of money with increasing stacks of coins with a calendar and clock in the background.

Image source: Getty Images

DocuSign: a new opportunity in contract lifecycle management

DocuSign is best known for its e-signature product that is becoming the way contracts get finalized in our coronavirus work-from-home world of today. But the e-signature is only one step in a long process to prepare, sign, act on, and manage contracts. This is where DocuSign's new contract lifecycle management (CLM) tools as part of its Agreement Cloud are so powerful.

One customer, Unilever, uses these tools to create contracts that have cut the time to draft new contracts by 80% and reduced the time to complete contracts by half. Unilever rolled out these tools to 70 countries, enabling contracts to be generated in four different languages.

With just about every function in today's enterprise using contracts to get things done, the opportunity for this software is huge. Management thinks the contract lifecycle management business could be just as big as its e-signature business, effectively doubling its addressable market. With its CLM business just getting started, this digital transformation trend could power growth for DocuSign for decades to come.

MercadoLibre: the leader in a budding e-commerce market

MercadoLibre is the leading e-commerce retailer for Latin America and has been operating in the region since 1999. The region has a population of 638 million and a fast-growing set of internet users that now numbers 362 million. But purchasing goods online is still in its infancy. Research firm eMarketer reported that in 2019, Latin America's online sales grew 24% from the previous year to reach just 4.4% of total retail sales. The coronavirus is accelerating the e-commerce trend in the region, and MercadoLibre is positioned to benefit.

The company has built an extensive ecosystem of six complementary services with its payments segment being the fastest growing. Not only does its payment services help customers make online purchases on its website; it also enables them to pay for goods digitally in local stores. With the company taking a small cut of every payment transaction on its platform, this segment is set to bring in more revenue than its e-commerce operation in the coming years. 

With the convenience of online stores and electronic payments, MercadoLibre is well positioned to ride these growing trends for the next 20 years and beyond.

The waiting is the hardest part

Buying shares of a company new to your portfolio can be exciting. But once you own a piece of the business, watching the stock price change day to day can sometimes be nerve-racking with your hard-earned money on the line. The best investors know that patience is key to your success.

This trio of stocks is set to grow over the next few decades and reward those investors who hold on for the ride. Singer Tom Petty nailed it when he sang that "the waiting is the hardest part." Most of investing is just waiting, so buy a few shares of one or all of these stocks today and just wait. When you finally get to 2040, chances are you will be able to look back and be happy you did.