Commit 44b1a31
Skip decoding completely during count and improve SK count perf by 20x
Summary:
8.0 is taking a new approach with doing counts - MySQL will call handler::records / records_with_index which will then use rnd_init+rnd_next / index_init+index_next to iterate through everything. If you try count(*) you'll see MyRocks 8.0 is actually much slower when iterating the table with secondary keys than 5.6 (the optimizer picks secondary key for whatever reason).
This is because MySQL no longer calls `handler::extra(KEY_READ)` so we no longer get the hints to only decode the key - instead we'll see that the SK is not covering so we fall back to PK, which dramatically slows down by *a lot*.
This fixes it by adding a m_iteration_only = true hint - with this hint we'll just quickly iterate through everything without any decoding nor falling back to PK.
Note even with this fix, if you compare MyRocks 8.0 with InnoDB 8.0, you'll see that InnoDB 8.0 is also much faster - this is because InnoDB overrides the implementation and iterate the records directly in parallel (default to 4). This is something we can do as well.
Reviewed By: Pushapgl
Differential Revision: D262727331 parent d1b129e commit 44b1a31
2 files changed
+36
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
7108 | 7109 | | |
7109 | 7110 | | |
7110 | 7111 | | |
| 7112 | + | |
7111 | 7113 | | |
7112 | 7114 | | |
7113 | 7115 | | |
| |||
9085 | 9087 | | |
9086 | 9088 | | |
9087 | 9089 | | |
| 9090 | + | |
| 9091 | + | |
| 9092 | + | |
| 9093 | + | |
| 9094 | + | |
9088 | 9095 | | |
9089 | 9096 | | |
9090 | 9097 | | |
| |||
9756 | 9763 | | |
9757 | 9764 | | |
9758 | 9765 | | |
| 9766 | + | |
| 9767 | + | |
| 9768 | + | |
| 9769 | + | |
| 9770 | + | |
| 9771 | + | |
| 9772 | + | |
| 9773 | + | |
| 9774 | + | |
| 9775 | + | |
| 9776 | + | |
| 9777 | + | |
| 9778 | + | |
| 9779 | + | |
| 9780 | + | |
| 9781 | + | |
9759 | 9782 | | |
9760 | 9783 | | |
9761 | 9784 | | |
| |||
11301 | 11324 | | |
11302 | 11325 | | |
11303 | 11326 | | |
11304 | | - | |
| 11327 | + | |
11305 | 11328 | | |
11306 | 11329 | | |
11307 | 11330 | | |
| |||
11349 | 11372 | | |
11350 | 11373 | | |
11351 | 11374 | | |
| 11375 | + | |
| 11376 | + | |
| 11377 | + | |
| 11378 | + | |
| 11379 | + | |
11352 | 11380 | | |
11353 | 11381 | | |
11354 | 11382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
275 | 278 | | |
276 | 279 | | |
277 | 280 | | |
| |||
1005 | 1008 | | |
1006 | 1009 | | |
1007 | 1010 | | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
1008 | 1015 | | |
1009 | 1016 | | |
1010 | 1017 | | |
| |||
0 commit comments