If I remember right, the K20D is higher tier, but older technology.
Pentax K20D vs. Pentax K-x vs. Pentax K-S1 - Pentax Camera Comparison - PentaxForums.com
Honestly, camera sensors have gone a long way since then. K-5 is already significantly better, and even the modern, affordable, K-S1 will beat cameras older than the K-r in many respects.
K20D is okay if you can get it for a really good price and don't demand things like high ISO, video mode, scene mode..
I would definitely recommend getting a used K-5 or K-S1. That said, I have seen some great photos taken with K20D posted on these forums, so I don't want to say its a terrible camera. Its a good camera. But by now it is fairly old and technology has gone on. Electronics do not age very well, in general.