- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitd168b66
committed
Enhance nbtree index tuple deletion.
Teach nbtree and heapam to cooperate in order to eagerly removeduplicate tuples representing dead MVCC versions. This is "bottom-updeletion". Each bottom-up deletion pass is triggered lazily in responseto a flood of versions on an nbtree leaf page. This usually involves a"logically unchanged index" hint (these are produced by the executormechanism added by commit9dc718b).The immediate goal of bottom-up index deletion is to avoid "unnecessary"page splits caused entirely by version duplicates. It naturally has aneven more useful effect, though: it acts as a backstop againstaccumulating an excessive number of index tuple versions for any given_logical row_. Bottom-up index deletion complements what we might nowcall "top-down index deletion": index vacuuming performed by VACUUM.Bottom-up index deletion responds to the immediate local needs ofqueries, while leaving it up to autovacuum to perform infrequent cleansweeps of the index. The overall effect is to avoid certainpathological performance issues related to "version churn" from UPDATEs.The previous tableam interface used by index AMs to perform tupledeletion (the table_compute_xid_horizon_for_tuples() function) has beenreplaced with a new interface that supports certain new requirements.Many (perhaps all) of the capabilities added to nbtree by this commitcould also be extended to other index AMs. That is left as work for alater commit.Extend deletion of LP_DEAD-marked index tuples in nbtree by adding logicto consider extra index tuples (that are not LP_DEAD-marked) fordeletion in passing. This increases the number of index tuples deletedsignificantly in many cases. The LP_DEAD deletion process (which is nowcalled "simple deletion" to clearly distinguish it from bottom-updeletion) won't usually need to visit any extra table blocks to checkthese extra tuples. We have to visit the same table blocks anyway togenerate a latestRemovedXid value (at least in the common case where theindex deletion operation's WAL record needs such a value).Testing has shown that the "extra tuples" simple deletion enhancementincreases the number of index tuples deleted with almost any workloadthat has LP_DEAD bits set in leaf pages. That is, it almost never failsto delete at least a few extra index tuples. It helps most of all incases that happen to naturally have a lot of delete-safe tuples. It'snot uncommon for an individual deletion operation to end up deleting anorder of magnitude more index tuples compared to the old naive approach(e.g., custom instrumentation of the patch shows that this happensfairly often when the regression tests are run).Add a further enhancement that augments simple deletion and bottom-updeletion in indexes that make use of deduplication: Teach nbtree's_bt_delitems_delete() function to support granular TID deletion inposting list tuples. It is now possible to delete individual TIDs fromposting list tuples provided the TIDs have a tableam block number of atable block that gets visited as part of the deletion process (visitingthe table block can be triggered directly or indirectly). Setting theLP_DEAD bit of a posting list tuple is still an all-or-nothing thing,but that matters much less now that deletion only needs to start outwith the right _general_ idea about which index tuples are deletable.Bump XLOG_PAGE_MAGIC because xl_btree_delete changed.No bump in BTREE_VERSION, since there are no changes to the on-diskrepresentation of nbtree indexes. Indexes built on PostgreSQL 12 orPostgreSQL 13 will automatically benefit from bottom-up index deletion(i.e. no reindexing required) following a pg_upgrade. The enhancementto simple deletion is available with all B-Tree indexes following apg_upgrade, no matter what PostgreSQL version the user upgrades from.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Heikki Linnakangas <hlinnaka@iki.fi>Reviewed-By: Victor Yegorov <vyegorov@gmail.com>Discussion:https://postgr.es/m/CAH2-Wzm+maE3apHB8NOtmM=p-DO65j2V5GzAWCOEEuy3JZgb2g@mail.gmail.com1 parent9dc718b commitd168b66
File tree
19 files changed
+2112
-442
lines changed- doc/src/sgml
- ref
- src
- backend/access
- heap
- index
- nbtree
- rmgrdesc
- table
- include/access
19 files changed
+2112
-442
lines changedLines changed: 124 additions & 28 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
629 | 629 |
| |
630 | 630 |
| |
631 | 631 |
| |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
632 | 735 |
| |
633 | 736 |
| |
634 | 737 |
| |
| |||
666 | 769 |
| |
667 | 770 |
| |
668 | 771 |
| |
669 |
| - | |
670 |
| - | |
671 |
| - | |
672 |
| - | |
673 |
| - | |
674 |
| - | |
675 |
| - | |
676 |
| - | |
677 |
| - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
678 | 783 |
| |
679 | 784 |
| |
680 | 785 |
| |
| |||
702 | 807 |
| |
703 | 808 |
| |
704 | 809 |
| |
705 |
| - | |
706 |
| - | |
707 |
| - | |
708 |
| - | |
709 |
| - | |
710 |
| - | |
711 |
| - | |
712 |
| - | |
713 |
| - | |
714 |
| - | |
715 |
| - | |
716 |
| - | |
717 |
| - | |
718 |
| - | |
719 |
| - | |
720 |
| - | |
721 |
| - | |
722 |
| - | |
723 |
| - | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
724 | 820 |
| |
725 | 821 |
| |
726 | 822 |
| |
|
Lines changed: 29 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
386 | 386 |
| |
387 | 387 |
| |
388 | 388 |
| |
389 |
| - | |
| 389 | + | |
390 | 390 |
| |
391 | 391 |
| |
392 | 392 |
| |
393 |
| - | |
| 393 | + | |
394 | 394 |
| |
395 |
| - | |
396 |
| - | |
397 |
| - | |
398 |
| - | |
399 |
| - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
400 | 422 |
| |
401 | 423 |
| |
402 | 424 |
| |
|
0 commit comments
Comments
(0)