I am not a cook. Since graduating college, I’ve only lived in very large, very dense cities — Hong Kong, Tokyo, New York — and in very small apartments. I once went more than two years without actually connecting my stove to a gas supply. The inside of my refrigerator rarely contained more than beer, half-and-half and the remains of whatever I’d ordered from the Thai takeout place the night before — or, if I’m being honest, the week before. My cell phone was my main cooking utensil.

My urban foraging method of food consumption wasn’t just about laziness, though. Without a car — I haven’t driven one regularly since high school — it’s always been difficult for me to get to a large market and bring home a decent assortment of groceries. I’m usually left with whatever I can carry from the local bodega — or, because I live in Brooklyn, extremely expensive (but high-quality!) organic produce.

But that’s changed lately, thanks to the grocery-delivery service FreshDirect. I can order groceries online, and FreshDirect will deliver to my door for free. (Sound familiar? The great Web 1.0 flop Webvan had a similar business model. Times have changed.) For someone who hates shopping for food almost as much as I hate cooking it, FreshDirect is brilliant — and a little decadent. I always felt a bit guilty when I punched in an order. Surely a service that drives my groceries right to my doorstop must be worse for the environment than buying my own.

Guess again. A new study in the Journal of the Transportation Research Forum shows that ordering groceries for delivery online is actually much greener than driving to the store and buying them yourself. A lot greener — the study found that delivery-service trucks produced 20% to 75% less carbon dioxide than the corresponding personal vehicles driven to and from a grocery store. If the delivery service employed routes that clustered customers together, to minimize trips, the savings were even higher.

That shouldn’t be surprising, as Anne Goodchild, associate professor of civil and environmental engineering at the University of Washington and a co-author of the paper, put it in a statement:

A lot of times people think they have to inconvenience themselves to be greener, and that actually isn’t the case here. From an environmental perspective, grocery delivery services overwhelmingly can provide emissions reductions.

A fully loaded delivery truck making multiple stops can deliver far more food per mile than a single-family minivan making its weekly trip to the supermarket. And the denser the urban area an online delivery service serves, the greener it will be. Indeed, it’s not the delivery service that’s green so much as it is the city itself. The population density of Brooklyn is over 34,000 per square mile, compared with a little less than 90 people per square mile for the U.S. as a whole. It can’t be said enough: the greenest thing any of us can do is live in dense cities, or at the very least, support policies that enable greater population density.

But just because FreshDirect is green doesn’t mean every aspect of living in the city is necessarily carbon-friendly. Take the hip trend of urban farming — both actually growing food in the city and farmers’ markets. As Will Boisvert wrote in an excellent piece in the New York Observer last week (hat tip to Keith Kloor for pointing me to the article), as lovely as urban farming is, it’s actually a very inefficient way to produce and sell food:

A typical semi truck, meticulously packed and scheduled by corporate bean-counters, will carry 20 tons of food six miles or so on a gallon of diesel — that’s 120 ton-miles per gallon, in the jargon of freight fuel-efficiency. A freight train gets a whopping 480 ton-miles per gallon. Compare them with, say, the local farmers at the Union Square Greenmarket, whose light trucks and vans typically haul more dead weight — farm-stand, vehicle and driver — than produce. The most fuel-efficient farmer I talked to there reckoned that at peak harvest he burned nine gallons of diesel to bring two tons of potatoes 127 miles from Roscoe, N.Y., for an efficiency of 28 ton-miles per gallon. Hauling each spud from upstate thus requires as much fuel as moving it 585 miles by corporate semi or 2,340 miles by rail. Those disparities hold even for short intra-city trips: if a cargo van consumes just a gallon of gas hustling 200 pounds of tomatoes from a Brooklyn micro-farm to a Midtown market, it will burn more fuel per tomato than a fully loaded semi would bringing them up from Florida.

Again, it comes down to efficiency. Don’t get me wrong — I love my local farmers’ market, and I was even part of a community sponsored agriculture (CSA) last year that delivered locally produced food to my neighborhood. But I do it because I like the produce and because I like the idea of helping out New York State farmers — not because I think it’s better for the planet. (Boisvert has a great line about CSAs, which can be extremely unpredictable: “In fact, if you want to get technical, a CSA membership is less a purchase of food than a speculative investment in produce futures; JPMorgan should open a trading desk.”) There are clear intangible benefits of urban farming — community development, the fostering of a greater connection to the land and, of course, quality. And there are definitely problems with conventional farming, problems that range from animal-welfare issues to fertilizer runoff to warped public subsidies. But for most of us, local food is still more of a luxury than a green necessity.

The only way we’re going to thrive sustainably in a hot and crowded world is through density and efficiency. That is as true for food as it is for energy. FreshDirect and other online grocery-delivery services fit that category. Farmers’ markets and urban agriculture — less so.