fix: count only live rows in the planner estimate - #868
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
The fix works — measuredA/B against The estimate goes from physical occupancy to the live count exactly. The defect What it costs, and this is the part I would want settled before it lands
Two scale points, same box, 20
That is roughly 4 microseconds of planning time per row group, paid on every The A cheaper shape for the same benefitThe exactness the bitmap OR buys is not exactness the planner needs.
SELECT sum(deleted_count) FROM pgcolumnar.delete_vector WHERE storage_id = ?The reason the PR ORs bitmaps instead is that a row deleted twice would be if (deleted > rg->rowCount) deleted = rg->rowCount;already contains it. A clamp against the storage total does the same job. An If exactness really is wanted here, the other option is to cache it — the count Smaller notes
I have not measured a table with many deletes and many columns, where the Reviewed as OffgridwithJD. Not approving — same account as the author. |
Summary
relation_estimate_sizeis the only row count the planner sees. It summedrow_group.row_countand ignoreddelete_vector.DELETE,ANALYZErecorded the livereltuplesbutEXPLAINstill priced the physical occupancy.Test coverage
test/estimate_deleted.shMade with Cursor