Database software provider MongoDB (MDB 0.06%) reported impressive revenue growth in the second quarter that was far ahead of analyst expectations. Total revenue soared 40% year over year to $423.8 million, despite a tough macroeconomic environment.

Investors shouldn't get too excited. The timing of multi-year contracts and the way those contracts are accounted for drove unusual revenue growth in MongoDB's non-cloud segment. Atlas, the company's managed cloud database offering, grew revenue by 38%. Atlas revenue is largely consumption-based, and consumption trends were negatively impacted by the state of the economy.

Atlas accounted for 63% of revenue in the second quarter, with most of the rest coming from MongoDB's Enterprise Advanced product. Typically, the former grows faster than the latter, but this wasn't the case in the second quarter. The benefit from this faster-than-usual growth will disappear in the third quarter, with MongoDB expecting total revenue to grow by a much slower 20%.

Timing and lumpiness

Enterprise Advanced is a collection of products that enterprise customers can license. This includes MongoDB's Enterprise Server, which is a version of its core database software with additional enterprise-level features. Customers can run this software anywhere, including in their own data centers.

While MongoDB has been making an effort to grow this business, Atlas has long been the star of the show. In the final quarter of 2022, for example, total revenue grew by 56% year over year while Atlas revenue surged by 85%.

The roles were reversed in the second quarter of this year, but only because of some multi-year deals that were renewed. When MongoDB inks a multi-year agreement for Enterprise Advanced, a portion of the revenue is recognized upfront. This means that multiple large multi-year renewals in a single quarter can boost revenue growth in that quarter.

That's exactly what happened in the second quarter. MongoDB renewed a multi-year agreement with Alibaba, and it closed additional deals that it wasn't expecting to close. This created a one-off increase in revenue. Notably, it did not boost free cash flow since actual cash payments generally occur annually and not upfront. MongoDB reported a free cash flow loss of $27 million in the quarter.

MongoDB expects to generate between $400 million and $404 million in revenue for the third quarter, which represents roughly 20% year-over-year growth and a sizable decline from the second quarter. Enterprise Advanced revenue is expected to slump compared to the second quarter since the company does not expect to sign nearly as many licensing deals.

Is MongoDB stock a buy?

Even with the revenue growth rate set to be cut in half in the third quarter, 20% year-over-year growth is nothing to sneeze at when many enterprise software companies are seeing harsher slowdowns. Clearly, MongoDB's core products continue to resonate with its customers.

The problem with MongoDB stock is the valuation. MongoDB is valued at about $28 billion, putting the price-to-sales ratio based on the midpoint of the company's full-year guidance at a staggering 17.5. MongoDB isn't profitable on a GAAP basis or free cash flow basis, although it is profitable on a non-GAAP basis. The price-to-earnings ratio based on non-GAAP earnings guidance is a lofty 170.

The bottom line: MongoDB is an extremely expensive stock. The 40% revenue growth during the second quarter was an anomaly. If growth going forward is closer to 20%, it's tough to justify this type of valuation.