Martijn van Oosterhout <kleptog@svana.org> writes:
> Since it's currently all for collecting statistics on tables, why can't it
> collect another type of statistic, like:
> - How often the estimator gets it wrong?
> [snip]
> Does anyone see any problems with this?
(1) forced overhead on *every* query.
(2) contention to update the same rows of pg_statistic (or wherever you
plan to store this info).
(3) okay, so the estimate was wrong; exactly which of the many
parameters that went into the estimate do you plan to twiddle?
What if it's not the parameter values that are at fault, but the
cost-model equations themselves?
Closed-loop feedback is a great thing when you understand the dynamics
of the system you intend to apply feedback control to. When you don't,
it's a great way to shoot yourself in the foot. Unfortunately I don't
think the PG optimizer falls in the first category at present.
regards, tom lane