Arista Networks (ANET -2.03%) stock has likely made many investors very happy. But it hasn't all been easy money. Over the past five years, shares have skyrocketed in value. However, there's a sneaky caveat to these returns.

Arista stock has been great, but not if you made this 1 mistake

If you had invested $200 into Arista stock exactly five years ago, you'd have $1,043 today. That's a terrific return. If you had invested that money into the S&P 500, for comparison, you'd only have around $374.

Over the past five years, Arista's stock price has been buoyed by rising sales. Since 2019, revenue has jumped by 157%. The stock's price-to-sales ratio, meanwhile, has grown from 8.5 to 16.8 over that time frame. So, not only has the company increased sales considerably, but the price the market is willing to pay for those sales has nearly doubled. In combination, this is what led to Arista's 422% performance over the last five years.

As with any legendary performance, there's a catch: Arista's rapid growth came after years of disappointment. From 2018 to 2021, for example, the stock price was effectively flat. Then, over just a handful of years, the stock price exploded, driven by rising demand and investor interest in high-performance computing stocks, especially those with any connection to the rise of artificial intelligence.

Arista's strong five-year performance is another reminder that patient investors are often the biggest winners. Those who traded in and out of the stock may have missed the stock's biggest moves. As Warren Buffett advised in a 1989 note to shareholders, "The stock market is a device for transferring money from the impatient to the patient."