Costco Wholesale (COST 1.01%) stock is a perennial winner, beating the market time and time again. Even as sales growth has essentially stalled, Costco stock is still ahead of the S&P 500 this year, with a 23% gains versus almost 20% for the index.

There's obviously something investors see in Costco that's compelling them to pick up shares even in this pressured economy. Let's check out what it is and whether you should buy shares, too.

Sales are slow, but membership is booming

Sales growth has slowed to a trickle at Costco. In its fiscal 2023's third quarter (ended May 7), sales increased 1.9% year over year. Comps inched up 0.3%, and U.S. comps declined 0.1%. This was even worse in June, when sales increased 0.4% over last year and U.S. comps declined 2.5%. In this inflationary environment, even Costco's low prices aren't resulting in strong sales growth.  

But just about every other metric that measures operational health is showing that Costco has momentum. In the third quarter, traffic increased 4.8% over last year, so this isn't an issue of losing customers--they're coming even more frequently. Average ticket was down 4.2% because customers are coming, but they're buying food and essentials and staying away from expensive, non-discretionary purchases. Interestingly, CFO Richard Galanti pointed out that customers are buying apparel "in a big way."

The most telling metrics about how Costco's doing, though, are the membership numbers. Membership increased 7% over last year in the third quarter, and renewal rates were at record highs of 90.5% globally and 92.6% in the U.S. and Canada. Customers aren't relinquishing membership while inflation is still strong, since it more than pays for itself in the rock-bottom prices Costco offers.

It's also important to remember that Costco enjoyed unprecedented growth for the first two years since the pandemic started, making it tough to keep building. But with its new customers and strong engagement, it should deliver higher growth when inflation stabilizes.

In some ways it's just getting started

One of the most compelling reasons to think Costco could still be a moneymaker is that it's nowhere near saturation. That's true even in the U.S., where it has 587 warehouse stores, but even more so internationally, where it has 268 more stores and is taking a measured approach to expanding.

Costco is opening 23 net new stores this fiscal year, and it plans to open 25 annually for the next five years before upping that to 30 for the following five. Notably, it's making strong inroads into China, where it recently opened its first store and where it plans to have six by the end of the year. 

Right now, it's still opening more stores in the U.S. than international locations, with 13 domestically this year and 10 outside of the U.S. Galanti thinks that should rebalance to about half and half in the coming years, but noted that each time he thinks Costco's reached saturation in the U.S., new opportunities come up. 

Is now the right time to buy?

At the current price, Costco stock trades at 41 times trailing-12-month earnings. That's not only objectively expensive, but it's also above recent averages. However, Costco stock trades at a premium because it's so reliable for gains. It also pays a dividend -- including a special dividend from time to time -- providing passive income.

Costco stock has beaten the market over almost any time frame, and as the time frame increases, so does the margin. Investors could wait for a pullback in the price before buying, but you can't time the market. If you believe in Costco's long-term growth story, Costco stock is a buy even now.