This article originally appeared in the Motley Fool.

Many parents worry about paying for college, but apparently, it really keeps some folks up at night. Gallup conducted interviews between 2001 and 2015 asking participants to rank their chief financial fears, and then divided that data into different subgroups. While retirement was the primary worry among most subgroups, for parents of children younger than 18, paying for college topped their lists of financial concerns.

This news isn't surprising given that the cost of college has consistently been climbing faster than inflation. But before you dedicate too many of your financial resources to college, make sure to keep your eyes on the ultimate prize: retirement.

Put retirement first, no matter what

If you have young children, you may be inclined to focus on college over retirement since you'll conceivably have more time to save for the latter. And there is some logic there. Many workers rely on the magic of compounding to reach both their college and retirement savings goals, but to truly take advantage of compounding, you need to give your money time to grow. If college is only five years away and retirement is 20 years away, it makes sense that you'd want to concentrate on higher education costs and catch up on retirement savings later on.

The problem with this approach is that putting too much money into your kids' education could cause you to come up short in retirement. As costly as college tuition might be, you're likely to face a world of retirement expenses that are more taxing than you'd imagine. (Healthcare, for example, is just one of them.) And if you hold off on retirement savings to pay for college, you'll narrow your compounding window and risk running out of money as a senior.

Remember, you can always borrow money for college, but you can't borrow money to pay for retirement. That said, just because you can take out loans on your kids' behalf doesn't mean you should. Morningstar reports that for every $1 of student debt you accumulate, you'll set your retirement savings back $0.35. This applies regardless of your age or income level. So if you decide to take out a $40,000 loan to pay for your children to attend college, you're likely to wind up with $14,000 less in retirement savings. Now that may not seem like much, but over the course of a 20-year retirement, that's $700 less per year to cover expenses like housing, transportation, and medical bills.

It's for this reason that you're better off putting retirement ahead of college and finding ways to minimize your higher education costs. That could mean encouraging your children to attend an in-state college and live at home during their studies. Or it could mean letting your kids take on more debt and allocating more of your money to your IRA or 401(k). Think about it this way: Your children have their whole lives ahead of them to pay off that debt. You, meanwhile, don't have nearly as much time to recover from student debt if you're in your late 40s or 50s, so you're better off saving your money for retirement.

Save wisely for college

Of course, none of this should be taken to mean that you shouldn't save for college at all. As long as you stay on track for retirement, there's no reason not to put whatever extra money you have into a college savings account. But if your goal is to make a sizable dent in those tuition bills, you need to save wisely.

While you have several options for saving for college, it pays to consider a 529 plan. The primary benefit of a 529 is that your money gets to grow on a tax-deferred basis until you're ready to withdraw it. And as long as you use that money for qualified higher education purposes, your withdrawals will be completely tax-free.

Just as importantly, 529 plans tend to offer higher returns than standard savings account. Remember how we talked about compounding earlier? If you save $200 a month in a savings account paying 1% interest, you'll have about $38,600 in 15 years. But if you put that money in a 529 plan that gives you an average annual 6% return, you'll have close to $56,000 in 15 years' time. Of course, you could achieve a similar return in a traditional brokerage account, but then you'll miss out on the tax breaks a 529 would otherwise give you.

No matter what steps you take to pay for your kids to go to college, don't make the mistake of derailing your retirement in the process. It's noble to want to give your children the best opportunities out there, but if you create a situation where you run out of money in retirement and need to fall back on their financial support, you won't be doing them any favors in the long run.

Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.