Costco's (COST -0.11%) stock has been on a tear over the last few years, thanks to strong earnings and dividends, but is it a pace the company -- and other membership stores -- can keep up during a recession?

That's the exact question many investors are posing, even as Costco continues to pump out strong earnings. Even though many Wall Street pundits expect yet another quarter of earnings increases when the company announces its fiscal year 2019 fourth-quarter earnings on Oct. 3, the question remains: Is Costco a strong long-term buy?

A young man compares the price of two products.

Image source: Getty Images.

Global asset management firm A.B. Bernstein thinks despite its strong performance, Costco is overvalued. Following the firm's downgrade of the stock to "underperform" on Sept. 19, Costco stock dropped 1.5% in one day. At the end of trading on Sept. 26, the stock price was 5.1 percentage points lower at $288.26 than it was at its all-time high of $303.76 on Sept. 6.

Costco is outperforming the sector

In the last two years, Costco stock has soared an impressive 82%. The company has done well to separate itself from the competition in the discount membership store sector, thanks to a focus on quality products at affordable prices.

Costco's P/E ratio (non-GAAP) is 36.54, compared to the sector median of 22.54. Its EV/EBITDA (enterprise value divided by earnings before interest, taxes, depreciation and amortization) is 20.28 compared to the sector median of 12.67.

Its main competitors in bulk sales membership-based retailer -- BJ's Wholesale Club and Sam's Club, a division of Walmart -- far underperform compared to Costco. BJ's has roughly 550 fewer stores than Costco, and Sam's Club -- its most direct competitor -- often competes with its parent company's big box store, since shoppers can choose to purchase at Walmart without the need to pay a monthly membership fee.

All this, of course, has led to Costco's stock being valued at a premium compared to its competitors.

Costco is churning out solid earnings

Investors continue to throw their support behind the company because of Costco's continued strong earnings.

In its last earnings call in May, the company reported that net sales increased 7.4% for the third quarter year-over-year, from $31.62 billion to $33.96 billion. For the first 36 weeks of the fiscal year, net sales increased 8.3%.

Third-quarter net income was $2.05 per diluted share ($906 million total), up more than 20% from the $1.70 ($750 million total) it was last year.

In all, Costco has sustained a solid rate of growth over the last three years, and that has continued to attract investors. In fact, it's been able to grow its earnings per share 15% annually over the last three years.

Numbers such as these have investors expecting solid returns from Costco, even as the stock slipped back in late September.

How would a recession affect Costco?

There's no denying that when a recession hits -- or even when there is a significant threat of an upcoming recession -- consumers begin to cut back on their spending. One of the first things they cut out is discretionary spending. Department stores and specialty boutiques often suffer as a result.

At the same time, though, consumers still must purchase goods such as groceries and everyday household items. In a recession, they may search even harder for a deal.

This focus on bargain hunting and buying smart can often benefit big box stores such as Walmart and Target (TGT -0.30%) as more consumers who aren't regular shoppers start looking for better deals during a recession. The question remains, though, whether consumers are still willing to shell out the entrance price for membership stores.

Perhaps there's no better way to analyze the potential effect of another recession than to look at the last one. Back in 2009, retail sales were down roughly 8% in the first 11 months of the year, according to the U.S. Census Bureau. At the same time, sales at superstores and warehouse stores increased 2%.

Back then, Costco had fewer stores (566) than Sam's Club (605) but still plenty more than BJ's (184). Now, of course, that has changed, with Costco taking the clear lead.

Contrary to what investors expected, people were not only unwilling to drop their membership, they were willing to pay the upfront membership dues in order to save more on goods in the long run. Costco's fiscal year 2009 net income of $1.1 billion represented a 15% decline year over year, but the positive signs from the year were that not only did membership renewals not decrease, but the company actually gained additional members in the process.

One major difference in the situation, though, is Costco didn't face as stiff competition from online retailers such as Amazon back in 2009. Today, the company will have to worry about whether consumers would drop their memberships to Costco in favor of a Prime membership at Amazon -- or choose to pay no membership fees at all.

Still, the results of 10 years ago can at least give investors hope that a recession won't necessarily, in and of itself, destroy Costco's performance.

Can Costco continue to outperform?

That's the main question on any potential new investor's mind. After several successful quarters in a row -- and with another potential positive one coming up -- investors may have to pay a premium to buy Costco stock. So far, that hasn't mattered, as the company continues to outperform expectations.

But as Costco closes out another fiscal year, and as the country creeps closer to a predicted recession, it may be wise to hold off on mass purchasing the company's stock. Even if Costco were able to weather the storm as it did back in 2009, there may be better opportunities to buy low on its stock, as some investors eventually dump it if future earnings aren't quite as strong.