At first glance, Dollar General (DG) and Walmart (WMT) look like they're cut from the same basic cloth. Walmart operates fewer but bigger stores, while Dollar General manages more but smaller stores. Walmart's selection is more varied due to its sheer size. If you're looking for the most-needed and most-consumed basics, though, both retailers have them.

From an investor's point of view, however, the two companies are quite different. One is a far better bet than the other... particularly right now. The better buy at this time is Walmart. Here's why.

Comparing and contrasting

While the two retailers are in the same general merchandise business, their business models are notably different. Walmart operates 4,684 stores in the United States, plus another 599 Sam's Club warehouses (and another 5,262 locales outside the U.S.). Its average supercenter covers about 190,000 square feet, and for obvious reasons they're located in relatively populated areas. The company boasts that 90% of U.S. residents live within 10 miles of some sort of Walmart store.

Dollar General is at the other end of all of those scales. The retailer's average unit only covers on the order of 8,000 square feet, and about 70% of its 19,294 stores are found in towns with populations of less than 20,000.

And yet, somehow roughly three-fourths of U.S. residents also live within five miles of a Dollar General locale. Clearly there's at least some geographic overlap between these two discount store chains.

Their respective location strategies and store-size strategies had been working for both companies for a long while. But beginning about eight years ago, things started changing. That's when now-former Dollar General CEO Todd Vasos took the helm, and immediately launched an aggressive expansion plan prioritizing the addition of more stores.

It worked -- sort of. Under his leadership, the retailer established around 7,000 new locations. This rapid growth, however, also exposed a couple of key challenges unique to Dollar General's approach to doing business.

Dollar General's big headaches

The first of these challenges is the logistical headache of managing nearly 20,000 locales paired with its relatively small store size. It's an inventory-management nightmare. Most of the stores don't have enough space to store and stage the merchandise they're receiving, nor do they have the staff needed to handle it. The U.S. Department of Labor's OSHA (Occupational Safety and Health Administration) has levied $16 million worth of fines against Dollar General since 2017 for merchandise blocking fire exits. Then there have been a number of store shutdowns by local fire marshals.

These safety gaffes are embarrassing, to be sure. But they also point to a bigger problem. That's the ever-growing levels of inventory sitting inside a store but not on a shelf where a customer can access it. That unsellable merchandise is effectively money that could be used to buy other goods and place them in other stores where they might be more marketable. Those nickels and dimes add up.

Notably, Dollar General's total inventory grew 20% year over year during the quarter ended in early May, far exceeding revenue growth of less than 7%. It's clearly got a long way to go to shore up its merchandise management process.

The second problem Dollar General faces that Walmart doesn't? It lacks a meaningful e-commerce presence. While Dollar General's website does facilitate online sales of certain items, it's a limited selection, and feels like a bit of an afterthought compared to how Walmart and Amazon cater to online shoppers.

In some ways it's not entirely fair. Eight years ago, Walmart wasn't exactly an e-commerce powerhouse either. Amazon Prime was still in its early days then as well, and didn't yet offer free next-day shipping on nearly everything. It wasn't unusual for the mostly rural customers that Dollar General was serving at that time to wait an additional day or two to receive an item ordered online.

The online marketplace has since changed dramatically. Numbers from Zippia indicate three-fourths of U.S. residents now shop online at least once per month, while nearly half of them do so at least once every two weeks. Moreover, the U.S. Department of Commerce reports online shopping reached a record-breaking $1.03 trillion last year, up another 8%, while the National Retail Federation suggests domestic e-commerce will grow at a comparable clip again this year.

Dollar General just isn't able to keep up with this shift.

Walmart wins, hands down

To its credit, Dollar General is working to fix much of what ails it. In April, for instance, the company hired former Wayfair executive Peggie Fort to become Dollar General's Vice President of Inventory and Demand Management. It's a start. She's got a massive amount of repair work to do, however, and in the meantime the retailer's missing out on a huge growth opportunity in e-commerce.

Walmart, meanwhile, is already great at e-commerce, and already enjoys enough scale (has enough room in its stores and warehouses, and enough workers) to manage whatever inventory levels it wishes to handle.

These operational differences don't always matter to investors. In this instance for these two particular retailers right now, though, they're hugely distinguishing factors that favor the Goliath over the David. And, yes, these differences are even starting to show up in their respective results. Take the hint.