If you owned shares of Costco Wholesale (COST 1.01%) for any meaningful length of time since early last year, then congratulations! You logged some big gains, either realized or unrealized. Better yet, if you're a multidecade shareholder, this stock has likely become a massive -- and massively rewarding -- piece of your portfolio.

There's another familiar name out there, however, that's quietly turned even more of its investors into millionaires. It's just done so for a slightly different but important reason. That company? Procter & Gamble (PG -0.78%).

The thing is, the reason P&G was so rewarding to shareholders in the past is still in place. The same can't necessarily be said of Costco.

Dividends make a surprisingly big difference

It's tough to make a true apples-to-apples comparison of these two consumer-oriented companies. They aren't exactly in the same business, after all, and one's been around far longer than the other. They each also have their own unique goals when it comes to rewarding shareholders.

Still, to the extent investors understand that every stock has its unique qualitative as well as quantitative characteristics, we can reasonably hold one of these names up against the other.

To this end, from nothing other than a price-based viewpoint, Costco is technically the better performer. Its stock has advanced more than 8,000% since it went public back in 1985. Wow. Procter & Gamble's been around for nearly two centuries, conversely, and has been publicly traded for decades. Since the mid-80s, though, P&G stock has gained a little less than 5,000%. Both are solid performances, but clearly, one's better than the other.

However, there's a dimension that is not being reflected by these numbers. That's dividends. Costco pays them, but only minimally. Procter & Gamble is much more serious about dishing them out. Not only does it make bigger dividend payments, but it's raised its annual payout every year for the past 67 years.

The end result? Since 1985, reinvesting the dividends paid by Procter in more shares of the company would have netted you a market-beating average annualized return of nearly 13%. If dividends were reinvested during this period, a $10,000 investment in Procter & Gamble then would be worth more than $1.1 million today.

How slow, boring ol' Procter & Gamble did it

Surprised? Don't be. Although most investors seem to prioritize their search for growth prospects these days, dividend income remains a big part of the market's overall returns. Numbers from mutual fund company Hartford indicate dividends accounted for 41% of the S&P 500's total returns between 1930 and 2022. And the numbers become even more impressive when you reinvest them in the index itself. Hartford goes on to say that 69% of the S&P 500's total returns between 1960 and 2022 were ultimately attributed to reinvested dividends.

The secrets of this success? For Procter, consistency is a big one. The company continued to dish out dividend payments even when economic turbulence was dragging the stock down. This ultimately meant more shares were bought at a discount, magnifying the rebounds once they took shape.

There's also the nature of Procter & Gamble's business and how well it does it.

Consumers will always need laundry detergent, toothpaste, and diapers. Procter is a leading name in all three categories, with its Tide, Crest, and Pampers brands. And that's just a sampling. It owns several category-leading brands, including Dawn dish detergent, Oral-B, and Gillette razors, just to name a few. It remains a market leader because it can afford to simply outspend its competitors when marketing its goods -- something Costco can't say.

It matters simply because this capacity to out-promote its rivals facilitates the very consistency that makes Procter a name worth reinvesting dividends in.

Procter can do it again, too

None of this is to suggest you absolutely must own Procter & Gamble over Costco. There's still a pretty good bullish case for holding Costco, too. Indeed, the stock is up more than 50% in just the past year and higher by more than 200% for the past five years. P&G shares are generating nowhere near that sort of performance.

That big gain from Costco is arguably an exception to the norm rather than its norm, however.

It's also not likely to hold. The stock is now trading at a forward-looking price/earnings ratio of 46, which is stunningly expensive for any retailer's stock. The market may well be rethinking this run-up soon, correcting the mistake with a sizable pullback.

Procter & Gamble shares aren't running that same degree of risk, valued at only 25 times this year's projected per-share profits.

That sets the stage for yet another reason P&G has created more millionaires than Costco has -- investors can comfortably, confidently hold onto it in good times and bad, whereas Costco's often-volatile nature means it isn't a name that's always easy to stick with. When a stock is uncomfortable to continue holding, however, that is often the time it's most important to do so.

Bottom line? You don't necessarily need to own sexy growth stocks to become a millionaire. Boring, slow-and-steady names are just as able to get the job done, if not more so. Moreover, the attributes that made Procter & Gamble such a great millionaire-maker over the course of the past 40 years could do the same in the coming 40 years. People are always going to need to do laundry and brush their teeth, after all.