For decades consumers have lost sleep over the frustrating intricacies of mattress selection. But there’s been a revolution in the once-sleepy mattress industry. New brands have been pouring into the market…foam and memory foam mattresses have been gaining ground on the venerable innerspring…and consumers now can easily buy high-quality mattresses online and in big-box stores such as warehouse clubs, not just in mattress and department stores.

These new options offer the potential for big savings and a more comfortable night’s sleep—but you still need to understand the choices and distinguish fact from hype.

Here’s what you really need to know now to get a good deal on a mattress you’ll love…

The “tried-and-true” test is often unreliable. The standard advice for mattress shoppers has long been to lie on a mattress in a store for at least 15 minutes to determine whether it feels comfortable. But I’ve studied thousands of consumer mattress reviews and complaints, and when you dig into this data, you discover that people are nearly as likely to be happy with mattresses bought online—mattresses they never tested—as they are with those bought in stores. That tells us that 15 minutes of lying fully clothed on a brand-new mattress in a showroom is not an effective way to judge whether it will be a comfortable place to spend eight hours every night.

Better ways to increase the odds that you will end up with a comfortable mattress…

Buy a medium or medium-firm  mattress. Mattresses are sold in “supportiveness” levels ranging from soft to extra firm—but it turns out that almost ­everyone is happiest with a medium or medium-firm model. And despite the conventional wisdom, a firm mattress usually is not best for reducing back pain. Rule of thumb: Back sleepers, stomach sleepers and people who weigh more than 230 pounds usually prefer medium-firm…while side sleepers and people who weigh less than 120 pounds usually prefer medium, though this can vary. (You might reasonably opt for firm if you intend to put a “mattress topper” on your mattress—see below.)

Buy from a seller that has a liberal return policy. The truth is, no matter how much you pay for a mattress and no matter which brand and type you select, there is a chance that you won’t like sleeping on it. The best solution is to buy from a company that will give you a hassle-free full refund if necessary. The best return policies these days are from direct-to-consumer online foam and hybrid foam/memory foam mattress sellers such as Casper (now also sold through Target)…LeesaPurple…and Tuft & Needle. Each offers 100-day, no-hassle, no-cost returns in the continental US. Usually you just contact the company, which will send a courier to pick up the mattress and donate it to a charity or recycle it if no charity is available.

Warehouse clubs generally have liberal return policies. However, a buyer usually must transport the mattress back to the store.

If you shop elsewhere, confirm that you can return your mattress at low or no cost if necessary after at least a month or two. Get this return policy in writing.

The most popular type of mattress is the least likely to satisfy. The classic innerspring mattress is far from the only option these days. New types of foam mattresses, in particular, have been gaining ground. But most people still end up buying an old-fashioned innerspring mattress—it’s what they’ve always slept on, so they assume it’s the safest choice. In fact, it’s the riskiest.

My research has found that only 64% of innerspring mattress buyers are satisfied with their mattresses—compared with 77% to 80% of buyers of other types of mattresses. One reason—­innerspring mattresses are about twice as likely as other types to develop permanent sags, dips or body impressions within three years of use, which is the leading cause of dissatisfaction with mattresses.

Also, some people who opt for innerspring fear that a foam mattress will “sleep hot” (make them feel too warm). But although about 10% of memory foam mattress users complain that their mattresses are uncomfortably hot—­because memory foam conforms closely around the sleeper’s body—foam mattresses that are mostly or entirely a type of regular foam rather than memory foam actually are even less likely than innerspring mattresses to generate heat complaints.

This doesn’t mean that every foam mattress is a good mattress. Foam and memory foam mattresses often fall short on “edge support”—sitting or sleeping near their perimeters can be a problem. And thin foam mattresses can flatten out under sleepers who weigh a lot. As with any type of product, quality varies from brand to brand and model to model.

But what if you’ve been happy with an innerspring mattress and really want to stick with that type? In that case, buy one—but perhaps not one with a ­“pillow top,” a thick extra layer of cushy padding on top. The pillow top often is the part of an innerspring mattress that develops a problematic dip or body impression. If you want the soft pillow-top feel, consider instead adding a “mattress topper” to a nonpillow-top mattress. Mattress toppers serve the same function as pillow tops but can be removed and replaced if they degrade. This strategy is likely to be a money saver, too—nonpillow-top mattresses tend to be at least 25% less expensive than comparable pillow tops, and highly rated mattress toppers are available online for just $30 to $100.

The best-known brands often are not the best. Mattress maker King Koil and the so-called “S” brands—Sealy, ­Serta, Simmons and Stearns & Foster—are among the best-known mattress brands, mainly because of their long histories and wide availability in stores. But these well-known brands tend to have some of the lowest customer satisfaction scores in the mattress industry—only 62% to 65% of buyers of these brands are satisfied with their mattresses.

The highest consumer satisfaction scores, ranging from 78% to 80% satisfied buyers, are earned by the new breed of Internet-sold foam and hybrid foam/memory foam mattress makers mentioned earlier—notably Casper…Purple…Tuft & Needle…and Leesa. Among innerspring mattress brands, relatively unknown web-sold Saatva registers the highest satisfaction score—81%—partly because of very strong customer service.

Other innerspring mattress brands that score relatively well in satisfaction include the upscale but little-known Hästens (77% satisfaction) and Aireloom/Kluft (75%)…and economical Ikea (70%).

In two other mattress categories, the most famous brands score well for satisfaction—but not for value—and there are great alternatives…

Tempur-Pedic, the biggest name in memory foam mattresses, has an 81% customer satisfaction score. But a company called  Zinus.com makes memory foam mattresses that have a 78% satisfaction score and cost just $250 to $300 versus $2,000 or more for most Tempur-Pedic mattresses. ­Zinus mattresses are sold on Amazon.com under the brand names “Sleep Master” and “Best Price”…and on Walmart.com under the brand name “Spa ­Sensations.”

Sleep Number is the biggest name in adjustable-firmness mattresses and has a 77% owner-satisfaction score—but ­lesser known adjustable brands Boyd, Habitat Furnishings, Innomax (sold at Sam’s Club as “Dual Digital” mattresses) and Personal Comfort all earn satisfaction scores of 78% to 82% and typically cost at least 15% less than comparable Sleep Number mattresses.