forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5f8727f
committed
VACUUM ANALYZE: Always update pg_class.reltuples.
vacuumlazy.c sometimes fails to update pg_class entries for each index(to ensure that pg_class.reltuples is current), even though analyze.cassumed that that must have happened during VACUUM ANALYZE. There areat least a couple of reasons for this. For example, vacuumlazy.c couldfail to update pg_class when the index AM indicated that its statisticsare merely an estimate, per the contract for amvacuumcleanup() routinesestablished by commite573459 back in 2006.Stop assuming that pg_class must have been updated with accuratestatistics within VACUUM ANALYZE -- update pg_class for indexes at thesame time as the table relation in all cases. That way VACUUM ANALYZEwill never fail to keep pg_class.reltuples reasonably accurate.The only downside of this approach (compared to the old approach) isthat it might inaccurately set pg_class.reltuples for indexes whose heaprelation ends up with the same inaccurate value anyway. This doesn'tseem too bad. We already consistently called vac_update_relstats() (toupdate pg_class) for the heap/table relation twice during any VACUUMANALYZE -- once in vacuumlazy.c, and once in analyze.c. We now makesure that we call vac_update_relstats() at least once (though oftentwice) for each index.This is follow up work to commit9f3665f, which dealt with issues inbtvacuumcleanup(). Technically this fixes an unrelated issue, though.btvacuumcleanup() no longer provides an accurate num_index_tuples valuefollowing commit9f3665f (when there was no btbulkdelete() call duringthe VACUUM operation in question), but hashvacuumcleanup() has worked inthe same way for many years now.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Masahiko Sawada <sawada.mshk@gmail.com>Discussion:https://postgr.es/m/CAH2-WzknxdComjhqo4SUxVFk_Q1171GJO2ZgHZ1Y6pion6u8rA@mail.gmail.comBackpatch: 13-, just like commit9f3665f.1 parent9f3665f commit5f8727f
2 files changed
+32
-21
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1738 | 1738 |
| |
1739 | 1739 |
| |
1740 | 1740 |
| |
1741 |
| - | |
| 1741 | + | |
| 1742 | + | |
1742 | 1743 |
| |
1743 | 1744 |
| |
1744 | 1745 |
| |
|
Lines changed: 30 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
600 | 600 |
| |
601 | 601 |
| |
602 | 602 |
| |
603 |
| - | |
604 |
| - | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
605 | 613 |
| |
606 | 614 |
| |
607 | 615 |
| |
608 | 616 |
| |
609 | 617 |
| |
610 | 618 |
| |
611 | 619 |
| |
| 620 | + | |
612 | 621 |
| |
613 | 622 |
| |
614 | 623 |
| |
| |||
617 | 626 |
| |
618 | 627 |
| |
619 | 628 |
| |
620 |
| - | |
621 | 629 |
| |
622 |
| - | |
623 |
| - | |
624 |
| - | |
625 |
| - | |
626 |
| - | |
627 |
| - | |
628 |
| - | |
| 630 | + | |
629 | 631 |
| |
630 | 632 |
| |
631 | 633 |
| |
| |||
641 | 643 |
| |
642 | 644 |
| |
643 | 645 |
| |
644 |
| - | |
645 | 646 |
| |
646 |
| - | |
647 |
| - | |
648 |
| - | |
649 |
| - | |
650 |
| - | |
651 |
| - | |
652 |
| - | |
653 |
| - | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
654 | 657 |
| |
655 | 658 |
| |
| 659 | + | |
656 | 660 |
| |
657 |
| - | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
658 | 668 |
| |
659 | 669 |
| |
660 | 670 |
| |
|
0 commit comments
Comments
(0)