If you're an investor who likes retail stocks, try to remember where you bought your last quart of milk or loaf of bread. It could help guide your next investment.

Buying stocks of food retailers can be a good long-term play. People always have to eat. That's why everyone from dollar stores to drugstores has built up their food aisles in the last three years. And that segment of retail looks ready to get busy on the investment front.

Grocery stores were under margin pressure last year, squeezed between food price inflation and shoppers' resistance to price hikes. Now the pressure has eased up, and with employment numbers rising, some price flexibility may creep into the scene this year.

An index of food prices which rose 20% in 2011 is expected to drop 3.2% in 2012, according to a forecast from the U.S. Department of Agriculture. The Fed's forecast found an index of world prices for corn, rice, wheat, and soybeans that had gone up 70% from mid-2010 to mid-2011 dropped 11% from May to December of 2011.

And as the economy improves, half the shoppers out there plan to spend more on groceries this year, according to a survey from consultants AlixPartners. They also found that another 40% will spend at least as much as before.

But the price battles will continue, because the competition in the segment won't let up. On one side, discounters like Wal-Mart (NYSE: WMT) and Target (NYSE: TGT) built up the grocery aisles during the recession to draw cash-strapped shoppers, and drugstores like Walgreen's and CVS now look like 7-Elevens.

Traditional grocery stores still account for 51% of all grocery sales, but mass merchants are already at 30% and coming strong, according to AlixPartners' survey. When it asked shoppers to name their three favorite grocers, Wal-Mart was tops with 46%. Target and Kroger (NYSE: KR) were far behind, tied for second with 16%.

So is it worth putting grocers' stocks in your shopping basket? Yes, but pick them as carefully as you choose your produce. Analysts believe grocers are heading into a period of consolidation, with holding companies becoming leaner and meaner.

After a few close calls in court, a bankruptcy judge just approved Yucaipa Co.'s plan to bring A&P, the parent of Pathmark and Food Emporium, out of Chapter 11 as a smaller company. Other grocers, such as Winn-Dixie and Bi-Lo, have announced mergers. Others are planning cutbacks, as Delhaize did when it closed 113 Food Lion stores at the start of the year.

This environment would work for market leaders like Kroger, Safeway, and special types like Whole Foods (Nasdaq: WFM), which should also benefit as shoppers loosen up at the cash register again.

Fools Jacob Roche and Brian Stoffel have already argued the pros and cons of Whole Foods. So let's steer clear for now, except to say that things will look better for "Whole Paycheck" when shoppers can afford $5 artichokes again.

Right now, analysts like Kroger, and it's not hard to see why. Its P/E stands around 12, compared to a 19.8 industry average, according to Morningstar's analysis, and it has shown same-store sales growth for 29 consecutive quarters. Its profit margin is a slim 1.3 (because it's been using gasoline as a loss-leader to build traffic, according to Morningstar) but its return on equity is 24%, nearly twice the industry average.

Citigroup just upgraded Kroger to a buy and placed it in its top list. Retail analyst Deborah Weinswig said it's positioned to pick up market share as grocers consolidate, and it has the lowest price gap against Wal-Mart, which is another competitive plus.

Safeway (NYSE: SWY) may not be sitting as comfortably as Kroger, but it is making improvements. It's focused on building customer loyalty instead of offering discounts that will hurt its margins, Weinswig points out. As Morningstar noted, it has spent $4.5 billion of incremental capital on improvements during the last decade, which will work if it manages to produce the kind of sales growth that has been hard to find during the Great Recession.

Safeway's P/E is only slightly higher than Kroger's, and while its results have not been as stellar, the stock got beat down a bit after its last earnings report. It's now trading near the middle of its 52-week range.

The company is holding an analyst meeting March 6 to present some new plans and give investors some guidance for the year, so expect some volatility that day as analysts absorb the information. Fool Sean Williams expects management to lower guidance due to high fuel prices and tight-fisted consumers, but we’d have to disagree, given all the factors mentioned above.

So, go ahead and pick up some grocery shares. They're on sale for a limited time.

If you like the idea of investing in the food industry but aren’t sure grocery stocks have the growth you’re looking for, you should take a look at our special free report: " 3 American Companies Set to Dominate the World ." In it you'll uncover three strong, branded American companies set to take emerging markets by storm with highly scalable operations. You can click here to access your free copy now.