"Richard Huxton" <dev@archonet.com> writes:
> Why doesn't PG (or any other system afaik) just have a first guess, run the
> query and then if the costs are horribly wrong cache the right result.
?? Knowing that your previous guess was wrong doesn't tell you what the
right answer is, especially not for the somewhat-different question that
the next query is likely to provide.
The real problem here is simply that PG hasn't been keeping adequately
detailed statistics. I'm currently working on improving that for 7.2...
see discussions over in pghackers if you are interested.
regards, tom lane