forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3ca930f
committed
Improve performance of get_actual_variable_range with recently-dead tuples.
In commitfccebe4, we hacked get_actual_variable_range() to scan theindex with SnapshotDirty, so that if there are many uncommitted tuplesat the end of the index range, it wouldn't laboriously scan through allof them looking for a live value to return. However, that didn't fix itfor the case of many recently-dead tuples at the end of the index;SnapshotDirty recognizes those as committed dead and so we're back tothe same problem.To improve the situation, invent a "SnapshotNonVacuumable" snapshot typeand use that instead. The reason this helps is that, if the snapshotrejects a given index entry, we know that the indexscan will mark thatindex entry as killed. This means the next get_actual_variable_range()scan will proceed past that entry without visiting the heap, making thescan a lot faster. We may end up accepting a recently-dead tuple asbeing the estimated extremal value, but that doesn't seem much worse thanthe compromise we made before to accept not-yet-committed extremal values.The cost of the scan is still proportional to the number of dead indexentries at the end of the range, so in the interval after a mass deletebut before VACUUM's cleaned up the mess, it's still possible forget_actual_variable_range() to take a noticeable amount of time, if you'vegot enough such dead entries. But the constant factor is much much betterthan before, since all we need to do with each index entry is test its"killed" bit.We chose to back-patch commitfccebe4 at the time, but I'm hesitant todo so here, because this form of the problem seems to affect many fewerpeople. Also, even when it happens, it's less bad than the case fixedby commitfccebe4 because we don't get the contention effects fromexpensive TransactionIdIsInProgress tests.Dmitriy Sarafannikov, reviewed by Andrey BorodinDiscussion:https://postgr.es/m/05C72CF7-B5F6-4DB9-8A09-5AC897653113@yandex.ru1 parentb976499 commit3ca930f
File tree
5 files changed
+65
-14
lines changed- src
- backend
- access/heap
- utils
- adt
- time
- include/utils
5 files changed
+65
-14
lines changedLines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2118 | 2118 |
| |
2119 | 2119 |
| |
2120 | 2120 |
| |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
2121 | 2124 |
| |
2122 | 2125 |
| |
2123 | 2126 |
| |
|
Lines changed: 27 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
142 | 142 |
| |
143 | 143 |
| |
144 | 144 |
| |
| 145 | + | |
145 | 146 |
| |
146 | 147 |
| |
147 | 148 |
| |
| |||
5328 | 5329 |
| |
5329 | 5330 |
| |
5330 | 5331 |
| |
5331 |
| - | |
| 5332 | + | |
5332 | 5333 |
| |
5333 | 5334 |
| |
5334 | 5335 |
| |
| |||
5351 | 5352 |
| |
5352 | 5353 |
| |
5353 | 5354 |
| |
5354 |
| - | |
| 5355 | + | |
5355 | 5356 |
| |
5356 | 5357 |
| |
5357 | 5358 |
| |
| |||
5373 | 5374 |
| |
5374 | 5375 |
| |
5375 | 5376 |
| |
5376 |
| - | |
5377 |
| - | |
5378 |
| - | |
5379 |
| - | |
5380 |
| - | |
5381 |
| - | |
5382 |
| - | |
5383 |
| - | |
5384 |
| - | |
| 5377 | + | |
| 5378 | + | |
| 5379 | + | |
| 5380 | + | |
| 5381 | + | |
| 5382 | + | |
| 5383 | + | |
| 5384 | + | |
| 5385 | + | |
| 5386 | + | |
| 5387 | + | |
| 5388 | + | |
| 5389 | + | |
| 5390 | + | |
| 5391 | + | |
| 5392 | + | |
| 5393 | + | |
| 5394 | + | |
| 5395 | + | |
| 5396 | + | |
5385 | 5397 |
| |
5386 |
| - | |
| 5398 | + | |
| 5399 | + | |
5387 | 5400 |
| |
5388 | 5401 |
| |
5389 | 5402 |
| |
| |||
5415 | 5428 |
| |
5416 | 5429 |
| |
5417 | 5430 |
| |
5418 |
| - | |
| 5431 | + | |
| 5432 | + | |
5419 | 5433 |
| |
5420 | 5434 |
| |
5421 | 5435 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
| 48 | + | |
| 49 | + | |
48 | 50 |
| |
49 | 51 |
| |
50 | 52 |
| |
| |||
1392 | 1394 |
| |
1393 | 1395 |
| |
1394 | 1396 |
| |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
1395 | 1417 |
| |
1396 | 1418 |
| |
1397 | 1419 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
| 44 | + | |
44 | 45 |
| |
45 | 46 |
| |
46 | 47 |
| |
| |||
56 | 57 |
| |
57 | 58 |
| |
58 | 59 |
| |
59 |
| - | |
| 60 | + | |
| 61 | + | |
60 | 62 |
| |
61 | 63 |
| |
62 | 64 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
66 | 66 |
| |
67 | 67 |
| |
68 | 68 |
| |
| 69 | + | |
| 70 | + | |
69 | 71 |
| |
70 | 72 |
| |
71 | 73 |
| |
| |||
100 | 102 |
| |
101 | 103 |
| |
102 | 104 |
| |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
103 | 113 |
| |
104 | 114 |
| |
105 | 115 |
| |
|
0 commit comments
Comments
(0)