Earlier this year, I bought shares of Costco Wholesale (COST -0.55%) during a pullback, expecting to hold them for a long time. With its massive purchasing power, rock-bottom prices, and customer loyalty, Costco has one of the deepest moats in the retail industry.

Costco has demonstrated the strength of its business in impressive fashion in recent months, causing Costco stock to rally far beyond its previous high. That has driven its valuation to new heights, requiring increasingly aggressive growth assumptions to justify the share price. As a result, while I continue to have great confidence in the business, I recently sold all of my Costco stock.

Proving the doubters wrong

Costco Wholesale was one of the retail industry's pandemic-era winners, as consumers looked to cut down on shopping trips by buying in bulk. Adjusted comparable sales (excluding the impact of changes in gas prices and foreign exchange rates) grew 9.2% in fiscal 2020, with double-digit growth in the second half of the fiscal year (roughly corresponding to the first six months of the pandemic).

The entrance to a Costco warehouse.

Image source: Costco Wholesale.

The company's strong performance during the pandemic made it a safe haven for investors last year. But after the U.S. and other developed countries began rolling out coronavirus vaccines, many investors feared that Costco would cede some of its market share gains as consumers returned to their previous shopping habits. This caused Costco stock to pull back from a high of nearly $400 last November to a low of $307 in March 2021.

I saw this pullback as a great opportunity to start a long-term investment in a rock-solid company. Sure enough, Costco's market share gains have proved stickier than the skeptics had assumed. Adjusted comparable sales growth accelerated in fiscal 2021, surging 13.4% for the year. That helped the warehouse club giant grow its earnings per share (EPS) 25% year over year to $11.27.

Costco has gotten off to a great start in fiscal 2022, too. Adjusted comparable sales rose 9.4% in September (the first month of the fiscal year), despite an extremely tough year-over-year comparison. October was even better, with adjusted comparable sales rising 11.8%.

As a result, investors have flocked back to Costco stock, driving it up more than 60% in the past eight months.

COST Chart

Costco Wholesale stock performance, data by YCharts.

How much growth is sustainable?

Analysts expect Costco to record about $214 billion of revenue in fiscal 2022: up 40% from the $153 billion it generated in fiscal 2019. That said, investors shouldn't expect Costco's revenue to continue rising at a double-digit compound annual growth rate as it has over the past three years.

First, inflation has accelerated to more than 5% recently, after averaging less than 2% over the past decade. Retailers like Costco are passing some cost increases through to consumers, driving faster revenue growth.

US Consumer Price Index YoY Chart

U.S. Consumer Price Index year-over-year growth, data by YCharts.

Inflation is unlikely to remain at this level for very long, though. If some of the recent price increases eventually reverse, that could drag on Costco's future revenue growth.

Second, the combination of government stimulus programs and reduced spending on services has freed up more consumer dollars for buying discretionary goods. That's helping nearly all retailers (including Costco). Indeed, U.S. retail sales rose 12.8% year over year in the third quarter of 2021. That pace of growth isn't sustainable in the long run.

Costco's revenue growth has historically been fairly volatile, with periods of rapid growth followed by slowdowns. As inflation cools off and consumer spending normalizes, Costco's revenue growth will likely moderate.

COST Revenue (Annual YoY Growth) Chart

Costco Wholesale revenue (annual year-over-year growth), data by YCharts.

The valuation looks stretched

Following its recent rally, Costco stock trades for 41 times its projected fiscal 2022 earnings: its highest earnings multiple in more than two decades. Clearly, investors have very high expectations today.

If Costco can grow its revenue at a double-digit annual rate for the next five years or more, Costco stock could perform very well despite its high valuation today. However, if revenue growth moderates as I expect -- leading to a corresponding slowdown in EPS growth -- the stock could struggle to move much higher over the next five years.

Costco stock is still a decent choice for long-term investors, thanks to its deep moat and long runway for growth. I may end up regretting my decision to sell. But at the moment, I see better opportunities elsewhere in the stock market.