Commit 759c2e8
committed
Make sure we're using indexes during rollbacks
Fixes #2083 (comment)
The planner sometimes uses a query similar to
Index Scan using tx_pkey on tx
Filter: (block_id >= $1)
the filter is not Index Cond, so this ends up in a sequential scan.
The index refers to the primary key and is only used for sorting.
Instead we want to use
Sort (top-N heapsort)
-> Index Scan using idx_tx_block_id
Index Cond: (block_id >= $1)
With this change we're forcing a similar plan
Aggregate
-> Index Scan using idx_tx_block_id
Index Cond: (block_id >= $1)
making sure we're using the Index Cond and then sorting.1 parent 3c8724b commit 759c2e8
1 file changed
Lines changed: 6 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | 61 | | |
64 | | - | |
| 62 | + | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
| |||
92 | 90 | | |
93 | 91 | | |
94 | 92 | | |
95 | | - | |
| 93 | + | |
96 | 94 | | |
97 | 95 | | |
98 | 96 | | |
99 | | - | |
100 | 97 | | |
101 | 98 | | |
102 | 99 | | |
103 | | - | |
| 100 | + | |
104 | 101 | | |
105 | 102 | | |
106 | 103 | | |
107 | | - | |
108 | | - | |
109 | 104 | | |
| 105 | + | |
110 | 106 | | |
111 | 107 | | |
112 | 108 | | |
| |||
0 commit comments