The stock market hasn't been kind to most sectors and businesses in 2022, but it has been especially brutal to unprofitable businesses. While profitability is certainly important, not all unprofitable businesses are equal. Sure, some have weak business models or are poorly run, but then there are others that are outstanding businesses and unprofitable for strategic reasons.

The market's current conservative approach and obsession with profitability, without any additional context or considerations, is creating some spectacular bargains. One such bargain is MongoDB (MDB -2.41%). Let's see why.

MongoDB's recent quarter was less than perfect 

Almost every modern company is a software company in some ways, and at the heart of each software app is a database like MongoDB. Developed on a relatively new paradigm of the NoSQL database, it offers greater flexibility and enables software development at a faster pace relative to traditional database models.

A person presenting data in an office meeting.

Image source: Getty Images.

Despite macro headwinds, MongoDB continued its momentum in its fiscal 2023 second quarter (ended July 31, 2022). The company added 1,800 new customers on a sequential basis, bringing its total customer count to 37,000, and revenue grew a solid 53% year over year to $304 million. Though MongoDB reported an adjusted net loss per share of $0.23, it beat consensus analyst expectations on both the top and bottom lines.

So far, that sounds like a good earnings story, but things went awry as the company discussed its profitability guidance for the fiscal third quarter and remainder of the year. MongoDB increased its adjusted net loss guidance for the current quarter to between $0.19 and $0.16 per share (prior estimate was $0.12), while full-year fiscal 2023 losses are expected to land between $0.35 and $0.28 per share (prior range of $0.31 to $0.16). 

This current market, highly sensitive to the bottom line, didn't take that news well. To add to the fire, non-GAAP operating margin shrank by two percentage points to negative 4%, and free cash flow flipped from $22.6 million in the prior-year period to a negative $48.6 million. MongoDB's widening losses in the fiscal second quarter confirmed to the market the near-term outlook for the company looks shaky, and the stock was punished severely the very next day with a 25% drop on Sept. 1, piling on the past year's bearish run along with the broad market.

MongoDB is focused on the long term, not the market's short term

MongoDB is still in the early stages of its growth. The company wants to invest aggressively to acquire new customers, increase the spending of existing customers, and ultimately grow its market share. That requires continuous product innovation by hiring and retaining the best-in-class engineering talent and developing a stellar sales force. And that's precisely where the company is putting its cash to work with its operating expenses clocking in at 109% of its revenue in the latest quarter. 

Besides growing market share, that high spending also makes sense when we consider the stickiness of MongoDB's offering. Once a new customer integrates its software apps with the database and migrates its mission-critical data, it becomes very difficult to switch away from it.

Furthermore, as customers' businesses grow, their use of MongoDB grows, leading to higher revenue for the company. That's evident in the company's dollar-based net expansion rate -- a measure of how much existing customers spend relative to the past year -- which came in at more than 120% in the fiscal second quarter, an impressive number and even more so in a period of economic contraction. 

Inverting the above argument, the effects of not investing in growth can be quite disastrous for MongoDB. The technology sector innovates and evolves at a rapid pace. Pausing innovation or slowing down new customer growth in a highly competitive space will lead to the loss of its leadership position.

MongoDB is making a strategic trade-off by forgoing short-term profits to capture the much more lucrative customer lifetime value over the long term. The focus on its long-term success is at odds with the current market's steadfast expectations for immediate profitability. And that disconnect, rather than any fundamental business factors, is keeping the stock in the doghouse.

A potential price dislocation and opportunity for investors

Databases are essential for the functioning of modern enterprises, and they're a nondiscretionary expenses. As seen by its continued growth, MongoDB is a top choice in the increasingly popular NoSQL database category. 

The focus of today's businesses on digital transformation and cloud adoption is a lasting tailwind for MongoDB. Year-over-year revenue for Atlas -- the company's cloud-based full-service offering -- grew 73% last quarter and now accounts for 64% of total revenue.

IDC estimates the database software market will be worth $85 billion in 2022 and projects it will reach $138 billion in 2026. With its current revenue outlook of about $1.2 billion for fiscal 2023, MongoDB has a huge runway in front of it.

The market is sour on MongoDB, but the company is rightly focused on its long-term trajectory. Shares are down 70% from their all-time high and are trading at a price-to-sales valuation of 11.2, close to the stock's five-year low. 

MDB PS Ratio Chart

Data by YCharts.

The stock will likely continue to be volatile with the market's fear, uncertainty, and doubt at such high levels, but for patient investors with long time horizons, now is a great time to make MongoDB a part of their portfolio.