Investing for the long haul is a long-proven way to build wealth, and patience is well-rewarded for those who pick well and let great companies take care of their businesses and their investors.

Heck, if you had put $10,000 in the S&P 500, say, 20 years ago and let it run, that stake would have returned a cool $58,940, counting dividends and share price gain through that metric known as total return.

Two people at a table and laptop in a warehouse.

Image source: Getty Images.

And if you'd rather choose individual equities, you don't have to chase growth stocks, with all their volatility. You can go slow and steady and just buy stocks in companies that do warehouses, office buildings, and shopping centers.

Here are three real estate investment trusts (REITs) that do just that, and each has soundly beaten the S&P 500 over the past two decades while providing respectable dividend yields along the way.

^SPXTR Chart

^SPXTR data by YCharts.

Prologis, the warehouse behemoth

Prologis (PLD -2.80%) is not just the biggest of industrial REITs; by market cap, it's the largest of the more than 225 publicly traded REITs. Behind that current valuation of about $128 billion is a portfolio of nearly a billion square feet of critical warehouse and distribution space serving 5,500 customers from about 4,700 facilities in 19 countries.

While on a particularly hot streak, like any other major owner of property in the very hot logistics space, San Francisco-based Prologis also has a long record of rewarding shareholders, providing a total return over the past 20 years of 1,140%, more than twice that of the S&P 500. It's raised its dividend for nine straight years, too, and is currently yielding about 1.83%.

Long-term demand for consumer e-commerce and business-to-business space doesn't appear to be abating, and Prologis looks to keep growing its share, continuing its internal expansion while reports circulate of possible acquisitions in Europe.

^SPXTR Chart

^SPXTR data by YCharts.

Alexandria Real Estate Equities does offices, but not just any offices

Alexandria Real Estate Equities (ARE -1.12%) provides office and laboratory space to many of the biggest names in the biopharma business, including the new Moderna headquarters near Boston.

This office REIT now has a market cap of about $33 billion, has been around since the 1990s, and concentrates its business in collaborative campus clusters in its hometown of San Diego and in and around San Francisco, Seattle, New York City, North Carolina's Research Triangle, and the Washington, D.C., area.

Alexandria has been steadily growing for a long time and has seen increased momentum as demand grew for its current space -- and anything more it could develop -- during the pandemic. That can be expected to help the company continue a streak of 12 years of dividend increases that are rewarding shareholders with a current yield of about 2.29%.

Federal Realty Investment Trust is a Dividend King

Federal Realty Investment Trust (FRT 0.34%) is a retail REIT, a somewhat battered sector in which to find a Dividend King. That means it's one of about 30 members of the S&P 500 that have raised its dividend for 50 straight years.

For Federal Realty, make that 54 years, giving this Bethesda, Maryland-based proprietor of high-quality, retail-based properties the longest such record among all REITs.

The company currently has a portfolio of about 104 properties, mostly in desirable areas in the Boston, San Francisco, Los Angeles, and Washington, D.C., markets. With a market cap of just shy of $10 billion, this REIT is the smallest of the three here, but its slow and steady performance through good times and bad stands it well for the future and currently pays shareholders a yield of about 3.50%.