Commit 2368e93
committed
Improve locking iterator performance
Issue: locking iterator is several times slower than the default
iterator in queries based on secondary keys.
For example:
select COUNT(*) from sbtest1 where k % 10 = 1 for update;
This query ends up iterating over the entire table, and in the end locks
the entire table, but does so by lots of small locks and seeks every
time.
This diff shows that by simply locking the entire table instead we can
improve the performance of the iterator by 50% - it's still slower than
the default implementation, but now it's much closer to it.
This modification of course results in overlocking in queries such as
select COUNT(*) from sbtest1 where k % 10 = 1 for update limit 3000;
where instead of locking only a few thousands records, with this change
we lock the entire table instead.
This change is in this form a proof of concept, for a real patch I
think we could go in two directions:
* instead of a hard coded value, make this an adjustable session
variable
* or instead of simply stopping after a threshold, continue locking in
linear or exponential batches1 parent 4a9df3b commit 2368e93
2 files changed
+28
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
126 | | - | |
| 129 | + | |
127 | 130 | | |
128 | 131 | | |
129 | 132 | | |
| |||
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
144 | | - | |
| 147 | + | |
145 | 148 | | |
146 | 149 | | |
147 | 150 | | |
| |||
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
156 | | - | |
| 159 | + | |
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
| |||
171 | 174 | | |
172 | 175 | | |
173 | 176 | | |
| 177 | + | |
| 178 | + | |
174 | 179 | | |
175 | 180 | | |
176 | 181 | | |
| |||
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
| |||
197 | 206 | | |
198 | 207 | | |
199 | 208 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
205 | 222 | | |
206 | 223 | | |
207 | 224 | | |
| |||
265 | 282 | | |
266 | 283 | | |
267 | 284 | | |
268 | | - | |
| 285 | + | |
269 | 286 | | |
270 | 287 | | |
271 | 288 | | |
| |||
276 | 293 | | |
277 | 294 | | |
278 | 295 | | |
279 | | - | |
| 296 | + | |
280 | 297 | | |
281 | 298 | | |
282 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
0 commit comments