forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit48c192c
committed
Revise pgstat's tracking of tuple changes to improve the reliability of
decisions about when to auto-analyze.The previous code depended on n_live_tuples + n_dead_tuples - last_anl_tuples,where all three of these numbers could be bad estimates from ANALYZE itself.Even worse, in the presence of a steady flow of HOT updates and matchingHOT-tuple reclamations, auto-analyze might never trigger at all, even if allthree numbers are exactly right, because n_dead_tuples could hold steady.To fix, replace last_anl_tuples with an accurately tracked count of the totalnumber of committed tuple inserts + updates + deletes since the last ANALYZEon the table. This can still be compared to the same threshold as before, butit's much more trustworthy than the old computation. Tracking this requiresone more intra-transaction counter per modified table within backends, but noadditional memory space in the stats collector. There probably isn't anymeasurable speed difference; if anything it might be a bit faster than before,since I was able to eliminate some per-tuple arithmetic operations in favor ofadding sums once per (sub)transaction.Also, simplify the logic around pgstat vacuum and analyze reporting messagesby not trying to fold VACUUM ANALYZE into a single pgstat message.The original thought behind this patch was to allow scheduling of analyzeson parent tables by artificially inflating their changes_since_analyze count.I've left that for a separate patch since this change seems to stand on itsown merit.1 parent6761cff commit48c192c
File tree
6 files changed
+152
-135
lines changed- src
- backend
- commands
- postmaster
- include
6 files changed
+152
-135
lines changedLines changed: 10 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
535 | 535 |
| |
536 | 536 |
| |
537 | 537 |
| |
538 |
| - | |
| 538 | + | |
| 539 | + | |
539 | 540 |
| |
540 | 541 |
| |
541 |
| - | |
542 | 542 |
| |
543 | 543 |
| |
544 | 544 |
| |
545 |
| - | |
546 |
| - | |
547 |
| - | |
548 | 545 |
| |
549 | 546 |
| |
550 | 547 |
| |
| |||
565 | 562 |
| |
566 | 563 |
| |
567 | 564 |
| |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
568 | 572 |
| |
569 | 573 |
| |
570 | 574 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
16 |
| - | |
| 16 | + | |
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
| |||
1332 | 1332 |
| |
1333 | 1333 |
| |
1334 | 1334 |
| |
1335 |
| - | |
1336 | 1335 |
| |
1337 | 1336 |
| |
1338 | 1337 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
32 |
| - | |
| 32 | + | |
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
| |||
237 | 237 |
| |
238 | 238 |
| |
239 | 239 |
| |
240 |
| - | |
241 | 240 |
| |
242 | 241 |
| |
243 | 242 |
| |
|
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
58 |
| - | |
| 58 | + | |
59 | 59 |
| |
60 | 60 |
| |
61 | 61 |
| |
| |||
2591 | 2591 |
| |
2592 | 2592 |
| |
2593 | 2593 |
| |
2594 |
| - | |
2595 |
| - | |
| 2594 | + | |
2596 | 2595 |
| |
2597 | 2596 |
| |
2598 | 2597 |
| |
|
0 commit comments
Comments
(0)