forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite2ac3fe
committed
Speed up rechecking if relation needs to be vacuumed or analyze in autovacuum.
After autovacuum collects the relations to vacuum or analyze, it recheckswhether each relation still needs to be vacuumed or analyzed before actuallydoing that. Previously this recheck could be a significant overheadespecially when there were a very large number of relations. This wasbecause each recheck forced the statistics to be refreshed, and the refreshof the statistics for a very large number of relations could cause heavyoverhead. There was the report that this issue caused autovacuum workersto have gotten “stuck” in a tight loop of table_recheck_autovac() thatrechecks whether a relation needs to be vacuumed or analyzed.This commit speeds up the recheck by making autovacuum worker reusethe previously-read statistics for the recheck if possible. Then if that"stale" statistics says that a relation still needs to be vacuumed or analyzed,autovacuum refreshes the statistics and does the recheck again.The benchmark shows that the more relations exist and autovacuum workersare running concurrently, the more this change reduces the autovacuumexecution time. For example, when there are 20,000 tables and 10 autovacuumworkers are running, the benchmark showed that the change improvedthe performance of autovacuum more than three times. On the other hand,even when there are only 1000 tables and only a single autovacuum workeris running, the benchmark didn't show any big performance regression bythe change.Firstly POC patch was proposed by Jim Nasby. As the result of discussion,we used Tatsuhito Kasahara's version of the patch using the approachsuggested by Tom Lane.Reported-by: Jim NasbyAuthor: Tatsuhito KasaharaReviewed-by: Masahiko Sawada, Fujii MasaoDiscussion:https://postgr.es/m/3FC6C2F2-8A47-44C0-B997-28830B5716D0@amazon.com1 parent4e43ee8 commite2ac3fe
1 file changed
+89
-19
lines changedLines changed: 89 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
328 | 328 |
| |
329 | 329 |
| |
330 | 330 |
| |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
331 | 335 |
| |
332 | 336 |
| |
333 | 337 |
| |
| |||
2797 | 2801 |
| |
2798 | 2802 |
| |
2799 | 2803 |
| |
2800 |
| - | |
2801 |
| - | |
2802 |
| - | |
2803 | 2804 |
| |
2804 | 2805 |
| |
2805 |
| - | |
2806 |
| - | |
2807 |
| - | |
2808 |
| - | |
2809 |
| - | |
2810 |
| - | |
| 2806 | + | |
2811 | 2807 |
| |
2812 | 2808 |
| |
2813 | 2809 |
| |
| |||
2831 | 2827 |
| |
2832 | 2828 |
| |
2833 | 2829 |
| |
2834 |
| - | |
2835 |
| - | |
2836 |
| - | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
2837 | 2847 |
| |
2838 |
| - | |
2839 |
| - | |
2840 |
| - | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
2841 | 2855 |
| |
2842 |
| - | |
2843 |
| - | |
2844 |
| - | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
2845 | 2862 |
| |
2846 | 2863 |
| |
2847 | 2864 |
| |
| |||
2929 | 2946 |
| |
2930 | 2947 |
| |
2931 | 2948 |
| |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
2932 | 2964 |
| |
2933 | 2965 |
| |
2934 | 2966 |
| |
2935 |
| - | |
2936 | 2967 |
| |
2937 | 2968 |
| |
2938 | 2969 |
| |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
2939 | 3009 |
| |
2940 | 3010 |
| |
2941 | 3011 |
| |
|
0 commit comments
Comments
(0)