I think investors can learn a lot by studying some of the historically best-performing stocks. This way, insights can be gained as to what specific traits can contribute to stellar returns. The valuable information obtained can then be used to find the next winning long-term investment. 

In the 20-year period that ended Sept. 8, Costco Wholesale (COST 1.01%) shares skyrocketed 1,630%, which means that a $10,000 investment would have turned into $173,000. For comparison's sake, the S&P 500 and the Nasdaq Composite rose 332% and 629%, respectively, during the same period. 

Let's dive into what makes Costco a special business, and whether it's a smart idea to buy the top retail stock right now.

Key factors leading to success 

Investors will quickly figure out that probably the most important factor that has helped Costco is its relentless focus on providing its customers with the lowest prices around. Whereas the typical markup at a major retailer could easily be over 20%, at Costco, merchandise is on average marked up by just 11%. That's by no means indicative of the quality of goods sold. Costco sells top brands, along with its incredibly popular Kirkland private label, in a wide range of product categories.

The business is only able to offer low prices because of its tremendous scale. As the world's third-largest retailer, Costco generated net sales of $223 billion in fiscal 2022 (ended Aug. 28 of last year). By having such powerful buying power, it is able to better negotiate favorable terms with its suppliers. And these savings are continuously passed to customers in the form of low prices. 

It's also worth mentioning that Costco operates a membership-based business model. For $60 a year, consumers can shop at the company's warehouses. This is almost a no-brainer decision for the 69.1 million membership households because they will likely achieve savings that exceed that annual cost in one shopping trip. This also drives loyalty, as exemplified by the record membership renewal rate of 92.6% in the U.S. and Canada last fiscal quarter. 

Strong financial performance 

The qualitative factors I just discussed, like the membership model and scale advantages, can't result in strong stock returns on their own. The missing piece is impressive financial performance, something Costco has clearly demonstrated. Between fiscal 2002 and fiscal 2022, net sales and diluted earnings per share increased at compound annual rates of 9.2% and 11.5%, respectively. Walmart, Costco's key rival, has seen these two metrics rise at much slower rates. 

For a business and a stock to perform this well for two decades is no small feat. I believe one other under-the-radar factor that has led to Costco's success is the industry it operates in. Being a brick-and-mortar retailer doesn't invite as much technological disruption as more tech-focused sectors. To be fair, e-commerce has been a major force that has impacted how consumers shop. But Costco has held its own against the threat of a business like Amazon, for example. And this bodes well for its future staying power.

Is Costco stock a buy right now? 

Investors have likely heard the saying that past performance doesn't guarantee future results. That's certainly true, and it helps us maintain some perspective as we look at the investment merits of Costco right now. 

As of this writing, Costco shares trade at a trailing price-to-earnings (P/E) ratio of 41. That is much more expensive than the valuation just at the start of 2023. But even more striking, the current P/E multiple is about twice as expensive as where Costco's stock sold exactly 20 years ago. Given the company's truly massive scale today, coupled with a valuation that seems to fully price in optimism, maybe investors should wait before buying the stock.