Robert Haas <robertmh...@gmail.com> writes: > Thinking about it more, there are really two ways to think about an > estimated row count.
> On the one hand, if you think of the row count estimate as the number > of rows that are going to pop out of a node, then it's always right to > think of a unique index as limiting the number of occurrences of a > given value to 1. But, if you think of the row count estimate as a way > of estimating the amount of work that the node has to do to produce > that output, then it isn't. The planner intends its row counts to be interpreted in the first way. We do have a rather indirect way of accounting for the cost of scanning dead tuples and such, which is that we scale scanning costs according to the measured physical size of the relation. That works better for I/O costs than it does for CPU costs, but it's not completely useless for the latter. In any case, we'd certainly not want to increase the scan's row count estimate for that, because that would falsely inflate our estimate of how much work upper plan levels have to do. Whatever happens at the scan level, the upper levels aren't going to see those dead tuples. regards, tom lane