Re: Preliminary patch for on-the-fly relpages/reltuples
От | Markus Bertheau |
---|---|
Тема | Re: Preliminary patch for on-the-fly relpages/reltuples |
Дата | |
Msg-id | 1102328081.3382.1.camel@fc3 обсуждение исходный текст |
Ответ на | Preliminary patch for on-the-fly relpages/reltuples estimation (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Preliminary patch for on-the-fly relpages/reltuples estimation
|
Список | pgsql-patches |
В Пнд, 29/11/2004 в 19:14 -0500, Tom Lane пишет: > + /* > + * lazy_update_relstats - update pg_class statistics for a table or index > + * > + * We always want to set relpages to an accurate value. However, for lazy > + * VACUUM it seems best to set reltuples to the average of the number of > + * rows before vacuuming and the number after vacuuming, rather than just > + * using the number after vacuuming. This will result in the best average > + * performance in a steady-state situation where VACUUMs are performed > + * regularly on a table of roughly constant size, assuming that the physical > + * number of pages in the table stays about the same throughout. (Note that > + * we do not apply the same logic to VACUUM FULL, because it repacks the table > + * and thereby boosts the tuple density.) > + */ > + static void > + lazy_update_relstats(Relation rel, BlockNumber num_pages, > + double num_tuples, double tuples_removed, > + bool hasindex) > + { > + num_tuples = ceil(num_tuples + tuples_removed * 0.5); Not understanding a thing about the PG source code, and judging from the variable names, wouldn't you want ceil(num_tuples + (num_tuples - tuples_removed) * 0.5) instead? > + vac_update_relstats(RelationGetRelid(rel), num_pages, num_tuples, > + hasindex); > } -- Markus Bertheau <twanger@bluetwanger.de>
В списке pgsql-patches по дате отправления: