http://www.mindspring.com/~phporter/econ.html
Mostly it is trial costs that bump the total price up.
And as far as keeping them in for an extended period of time, our legal system does allow a person who was convicted of a crime to appeal their conviction (because of evidence mishandling, bad police work, bad trial). The whole process can take years. If a person were to not contest the sentence they probably would be executed within a year.
And our judicial system is not about getting retribution for the victim or their familiy. It is about punishing a criminal for their crime against society.
And again, I don't see how we collectively are any better than the criminal if we murder him right back.