Although Dollar General (NYSE:DG) and Walmart (NYSE:WMT) are both technically in the same general merchandise retailing arena, they're not quite seen as head-to-head competitors. Walmart operates fewer but bigger stores, and Dollar General's strategy involves establishing more, smaller remote locations where competition is minimal. Dollar General stores are meant to offer the basics in a convenient format.

The world's biggest retailer may want to look over its shoulder, though. Dollar General is plowing through the so-called retail apocalypse like it's not even happening. It's able to do so because it's doing so many things right. Though not an existential threat, Dollar General could end up spoiling Walmart's plans for unfettered growth.

Clearly doing something right

Last quarter, Dollar General's $7 billion in revenue marked an 8.9% year-over-year improvement. Per-share profits rose 12.7%, growing from $1.26 a year earlier to $1.42 this time around. Most impressive of all, however, was the enviable average 4.6% increase in same-store sales.

Exterior of a Dollar General store

Image source: Dollar General.

To its rival's credit, Walmart's same-store sales growth figure of 3.2% was solid for the behemoth, which faces tougher comparisons just due to its sheer size. Dollar General is still boasting better (relative) growth, however, by virtue of an amazing pace of new store openings. It added 258 new stores to its network in the three-month stretch ending in October, maintaining an expansion pace that was set as far back as 2017. CEO Todd Vasos says he intends to open another 1,000 locations over the course of the coming year.

Yes, Dollar General is to be applauded for capitalizing on the same growing value mindset that's steered consumers away from mall department stores and toward the "treasure hunt" experience offered by off-price retailers like TJ Maxx, a TJX Companies subsidiary. But given that Dollar General's most direct competitor, Dollar Tree (NASDAQ:DLTR)isn't keeping pace with Dollar General by almost any measure, it's not the value orientation alone that's made it a champion within the general merchandise retailing category.

Rather, it's the sum total of doing several little things right that has made Dollar General a juggernaut.

It's the little things

Chief among those smart decisions is picking the right locations.

The retailer's strategy on this front is simple enough: Set up shop where competition is light. Roughly three-quarters of its stores are found in towns with populations of less than 20,000. Yet 75% of Americans now live within a five-minute drive of a Dollar General store, versus only 37% for a Walmart locale. That often puts its stores seemingly in retail's no man's land, just on the outskirts of a town on the way from one place to another. But as it turns out, for most consumers, that's not too far away.

Where Dollar General has become fiercely competitive, however, is inside those smartly located stores. Its product mix now includes about 40 private-label lines, which boast higher margins than third-party branded goods. All of its stores have offered dry goods and foods for some time, too, and most have been able to add chilled and frozen fare in recent years. Roughly 3,500 of its 16,000 locations, in fact, have added perishables to their mix, while a few hundred have already tacked on true produce departments. The company can handle the high-speed logistics needed to handle perishables, as it owns more than a couple hundred of its own trucks, giving it the flexibility to make deliveries on its own terms and schedule.

If where Dollar General is now seems like where Walmart was about forty years ago -- en route to its shift from being seen as a bargain venue to a supplier of consumer staples -- that's because it is. The one key exception? As noted, Dollar General is aiming to build more but smaller stores, whereas Walmart aimed to build sprawling shopping venues. That strategic difference may be a reflection of a change in how far consumers are willing to drive to make a purchase -- a distance shortened by an ever-improving selection at easier-to-shop Dollar Generals.

The head-turner

All of it in total should irritate Walmart, which got out of the small-format store business just a few years ago due to a lack of success with it. What should legitimately worry Walmart, however, is another subtle but critical shift. That is, all of these initiatives are starting to attract shoppers that earn more than Dollar General's traditional customer demographic of roughly $40,000 per year in household income.

GlobalData Retail's Neil Saunders wrote earlier this year that "we have seen some signs of a small increase in the number of middle-income consumer groups shopping at Dollar General since the start of the year, largely thanks to more pressure on household budgets from higher gas and energy prices." The reasoning may be up for debate, but Saunders' data jibes with other findings, like Thinknum Media's report from August indicating there were more dollar stores in middle-income ZIP codes than there were in higher- and lower-income ZIP codes combined. Earlier this year, Telsey Advisory Group analyst Joe Feldman told Fortune, "The dollar stores have become a lot more acceptable to all income demographics," pointing out that the Great Recession removed the stigma of shopping at such stores.

It's still only anecdotal evidence, but it's a lot of it. And it's a problem for Walmart simply because that's been Walmart's bread-and-butter customer. It will be interesting to see how, or even if, the megaretailer responds.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.