Costco Wholesale (COST -0.32%) has been one of the biggest retail winners during the COVID-19 pandemic. Its growth accelerated last quarter, as comparable sales skyrocketed 17.1%, excluding the impacts of currency fluctuations and gasoline price deflation.

For a second consecutive quarter, this double-digit sales growth drove a huge jump in Costco's earnings. The company's accelerating earnings growth suggests that Costco stock still has plenty of upside for long-term investors, despite carrying a lofty valuation after a 27% rally year to date.

COST Chart

Costco Wholesale year-to-date stock performance, data by YCharts.

Margin expansion continues

In the fourth quarter of fiscal 2020 -- the period ending in late August -- Costco posted adjusted comp sales growth of 14.1%. The uptick in sales allowed the company to leverage its normal operating expenses, while higher sales of fresh foods led to higher labor productivity and reduced spoilage. This drove substantial margin expansion, notwithstanding $281 million of incremental wage and cleaning costs related to the pandemic. Operating income jumped 31.9% on a 12.4% increase in total revenue.

Costco's results followed a similar trajectory last quarter. Total revenue increased 16.7% to $43.2 billion. Gross margin improved by approximately 0.5 percentage points, driven primarily by the same tailwinds of higher labor productivity and lower spoilage for fresh foods. Selling, general, and administrative expenses also declined modestly as a percentage of sales.

As a result, operating income surged 34.8% year over year to $1.43 billion, even though Costco incurred another $212 million of pandemic-related premium pay. Adjusted earnings per share reached $2.30, excluding various one-time tax benefits: up from $1.73 a year earlier. On average, analysts had expected adjusted EPS of $2.05.

Are Costco's gains sustainable?

Management has acknowledged that some of Costco's 2020 sales gains may prove temporary. With many restaurants offering limited service (or closed altogether), people are cooking more at home. That's boosting food-related sales at Costco. Meanwhile, high-income shoppers make up a substantial proportion of Costco's customer base. Many of these people have dramatically increased their spending on home-related items, using money they might have otherwise spent on vacations. Lastly, Costco is benefiting from its status as a one-stop shop where people can buy a wide variety of essentials and discretionary items in a single trip.

The entrance to a Costco warehouse

Image source: Costco Wholesale.

That said, Costco has cultivated extremely high customer loyalty. Membership renewal rates routinely exceed 90% in the U.S. and Canada (Costco's mature markets). The uptick in sales during the pandemic also appears to be encouraging more customers to upgrade to Costco's executive membership, which costs twice as much but offers 2% cash back on most purchases.

Thus, the retail giant has a good chance to retain many of the new members who have signed up this year, while the 2% cash reward will encourage newly minted executive members to shift more spending to Costco over time. Looking ahead, Costco will also benefit from an eventual revival in its hard-hit ancillary businesses, including its food courts, gas stations, and travel business. The March acquisition of logistics company Innovel Solutions should also help Costco increase its sales of big-ticket items in the years ahead.

A terrific business worth its premium valuation

Despite the strong Q1 results, Costco stock has barely budged since the earnings report. It now trades for a little more than 37 times Costco's projected fiscal 2021 earnings. That's certainly pricey: The S&P 500 as a whole is valued at 26 times forward earnings.

However, the 2021 analyst consensus implies EPS growth of just 11% for the rest of fiscal 2021. That seems extremely conservative in light of Costco's recent earnings trend. Furthermore, Costco's industry-leading prices should help it continue to gain market share for many years, driving strong sales growth. And with a pre-tax margin of just 1.2% excluding membership fee income last year, even modest margin improvements over time could turbocharge Costco's earnings growth.

Costco stock may not be a bargain anymore. But considering the company's massive long-term growth opportunities, it still holds plenty of potential for patient investors.