Retailers Walmart (WMT -0.11%) and Costco Wholesale (COST -0.88%) are two of the world's largest companies. They've also been remarkably successful investments. Over their lifetimes, they've each turned a $10,000 investment into millions of dollars.

However, that doesn't mean investors should necessarily run out and buy shares. Instead, take a step back and look at the big picture. Worth hundreds of billions of dollars today, these behemoths require a good entry price to pay off for your portfolio.

Do they warrant your hard-earned cash today?

Understanding the impact of large numbers

Walmart and Costco are massive companies today. Roughly 90% of the population lives within 10 miles of a Walmart Store. Costco isn't as widespread a business, but it's no slouch, with nearly $250 billion in annual sales.

These companies have been around for decades. Over time, as they sell more goods, they grow increasingly larger, and growth becomes increasingly challenging. Some call this the law of large numbers. I won't call it that because it's not absolute, but it's a common trend. You can see below that both companies' annual revenue growth has steadily decreased as yearly sales have increased.

WMT Revenue (Annual YoY Growth) Chart

WMT Revenue (Annual YoY Growth) data by YCharts

What was once 40% annual revenue growth is now mid-single-digit growth. Slower growth warrants a more conservative valuation and makes the price you pay crucial. Dramatically overpay for shares and run the risk of a slow-growth business taking years for earnings to catch up, leading to stagnating or declining share prices.

Evaluating today's valuations

Considering that, it's time to look at where these companies trade. Walmart is trading at over 25 times its estimated 2024 earnings, while Costco is trading at 46 times its earnings. Meanwhile, analysts believe Walmart's earnings will grow by an average of 6% to 7% annually over the next three to five years. For Costco, analysts expect earnings growth averaging just over 9% annually.

WMT PE Ratio (Forward) Chart

WMT PE Ratio (Forward) data by YCharts

Investors can look at the PEG ratio, which compares the company's earnings growth to the stock's valuation, to illustrate how expensive these valuations are. Generally, I buy stocks when the PEG ratio is under 2, ideally 1.5 or less.

Walmart's current PEG ratio is 3.7, and Costco's is 5.

That means Wall Street is paying a tremendous premium for these stocks. Both stocks will struggle to justify their current prices if growth doesn't exceed analysts' expectations.

The perils of overpaying

It's one thing if a quality business is a tad expensive, and you buy it and are willing to wait a bit for the earnings to fill out the valuation. But when you start getting into such a high premium as Walmart and Costco are at today, you risk severe losses. For instance, Costco could decline by 50% and still be considered overpriced.

Both Walmart and Costco are high-quality companies in positions of power in U.S. retail. But the stocks have run too far for the growth they will likely see over the coming years. Investors should avoid both names until dramatically better buying opportunities present themselves.