When planning for retirement, you are in the wealth-building stage. And the earlier you get started, the better. That's because you get the benefit of compounded earnings.

Long-term investments also allow you to ride out the waves that inevitably come from stock investing. When you buy high-quality companies, the short-term volatility becomes a distant memory. The key is to invest in stocks that have good growth potential over the long haul.

These two companies have not only proven themselves over time but also continue to have good prospects. This makes them ideal stocks to hold on to while they appreciate.

A couple standing in front of a large house.

Image source: Getty Images.

1. Costco

Costco Wholesale (COST -1.78%) offers a unique shopping experience that resonates with its members. Paying an annual fee, they get to shop at the giant warehouses, where the company offers a wide range of high-quality goods and services at attractive unit prices.

The quality and low prices make it hard for competitors to encroach on Costco's business. You can see this by looking at its membership data. Its renewal rate has hovered around 90% for several years. Plus, it consistently adds new members. Over the last five fiscal years, paid memberships have gone from 47.6 million to 58.1 million as of August 2020. During that time, operating income grew by nearly 50% to $5.4 billion.

Costco kept rolling this year, with adjusted same-store sales (comps) increasing by 15.2% for the first nine months of the year, and June's comps were also strong.

Plus, you can collect dividends over the years. While its 0.74% dividend yield isn't the highest, Costco has increased the payments annually since declaring its first dividend in 2004. This includes a 13% raise in May to $0.79 a quarter. Plus, it has rewarded shareholders with large special dividends periodically. The last one was in December when it paid $10. The previous one was in 2017, paying an extra $5 to shareholders.

2. Walmart

Walmart (WMT -0.35%) opened its first discount store nearly six decades ago, and while many other retailers have failed during that span, it has thrived. It's done so by keeping costs down and passing these savings on to the customer in the form of low prices. In fact, other retailers have a hard time competing with Walmart's prices.

It has also kept moving forward to keep up with what its customers want and need. It created e-commerce sites in 2000 and continued innovating, moving ahead with omnichannel initiatives that focus on more convenient and faster delivery options. This includes launching a subscription service, Walmart+, which offers customers fast delivery, gas discounts, and a more efficient checkout process at the stores. With its low prices and convenient delivery and pickup options, this allows Walmart to keep up with Amazon (NASDAQ: AMZN).

It's not done investing for the future, either. Management plans to increase this year's capital expenditures by 40% to $14 billion, focusing on items like the supply chain, automation, and customer-facing initiatives.

Meanwhile, Walmart continues to show improving results. Last year, its adjusted revenue grew by 7.7% to $564.2 billion, propelling operating income 9.3% higher.

In the first quarter, revenue was up by about 2% to $137.4 billion, but this was held down by business divestitures. However, operating income rose by over 31%. Excluding asset sales from the year-ago figures, management expects a low to middle single-digit percentage increase in sales this year, and operating income to rise by the high single-digits.

Walmart has proven itself a reliable dividend payer, too. It has raised the payment every year since its first one in 1974. The stock's dividend yield is 1.6%.

When contemplating retirement investments, if you start early enough, patience will not only prove a virtue but a genuine path to more money. However, the key is to pick the right long-term investments. Fortunately, Costco and Walmart have sound futures based on simple businesses executed very well.