This article was updated on April 12, 2016.

Investors generally have to pay close attention to the impact of taxes on their portfolios, especially when they decide to sell a stock that has gone up in value. Tracking cost basis is incredibly important to make sure you don't overpay your taxes on capital gains in a regular taxable account. For IRAs, though, the rules are different, and cost basis plays a more limited role in how retirement accounts get taxed. With a couple of key exceptions, cost basis almost never comes into play in an IRA.

Why cost basis usually isn't important for an IRA
The whole idea of cost basis goes toward figuring out exactly how much of an investor's proceeds from a sale represent true profit versus merely returning the original cash used to make the investment in the first place. In a taxable account, you only get taxed on the profit, and so measuring cost basis in order to calculate the appropriate tax is crucial.

For a traditional IRA, though, most accountholders don't have any cost basis as such. That's because nearly all IRA contributions are deductible at the time they're made, and so when the accountholder starts taking distributions in retirement, the full amount of each distribution is subject to tax. In other words, because you get a tax benefit by contributing to an IRA that you then essentially have to pay back when you take IRA withdrawals, the IRS doesn't draw a distinction between the cash you contributed and the appreciation in your investments over time.

The same is generally true with a Roth IRA. In contrast to traditional IRAs, Roth IRAs don't give you an upfront tax break. However, as long as you follow all the rules to qualify, then your Roth IRA withdrawals in retirement will be tax-free, regardless of how much your investments have appreciated in value in the interim.

Exceptions to the rule
The cost basis of a particular investment is never important for an IRA. However, there are a couple of situations in which the tax basis of your entire retirement account can be important.

The first exception applies if you've made nondeductible contributions to a traditional IRA. If the total amount of nondeductible contributions you've made is larger than the total value of the account, then you can claim the resulting loss on your tax return. Rather than going on Schedule D like capital gains and losses, this loss is a miscellaneous itemized deduction, and so is only available to those who itemize their deductions and who have total miscellaneous deductions that exceed 2% of adjusted gross income. A similar rule applies to Roth IRAs, where all contributions are nondeductible.

The other exception involves distributions from Roth IRAs that don't meet the various qualification rules for tax-free treatment. In general, withdrawals from Roth IRAs are treated first as being taken from contributions, and then from earnings. Even if a distribution violates provisions like the five-year rule following when you establish a Roth, you can withdraw up to the total amount of your contributions -- a figure that looks like cost basis without really matching up to it -- without tax. Only after you go beyond that amount and start drawing on earnings will penalty provisions start to apply.

In general, these two exceptions rarely occur, and so maintaining true cost-basis records for an IRA isn't necessary. Nevertheless, it can be useful to compare how much you initially contributed to your eventual account balance to see how much your money has grown over time.

The $15,978 Social Security bonus most retirees completely overlook
If you're like most Americans, you're a few years (or more) behind on your retirement savings. But a handful of little-known "Social Security secrets" could help ensure a boost in your retirement income. In fact, one MarketWatch reporter argues that if more Americans knew about this, the government would have to shell out an extra $10 billion annually. For example: one easy, 17-minute trick could pay you as much as $15,978 more... each year! Once you learn how to take advantage of all these loopholes, we think you could retire confidently with the peace of mind we're all after. Simply click here to discover how you can take advantage of these strategies.

This article is part of The Motley Fool's Knowledge Center, which was created based on the collected wisdom of a fantastic community of investors. We'd love to hear your questions, thoughts, and opinions on the Knowledge Center in general or this page in particular. Your input will help us help the world invest, better! Email us at knowledgecenter@fool.com. Thanks -- and Fool on!

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.