sql: improve vdbe_field_ref fetcher
Vdbe field ref is a dynamic index over tuple fields storing offsets to each field and filling the offset array on demand. It is highly used in SQL, because it strongly relies on fast and repetitive access to any field, not only indexed. There is an optimisation for the case when a requested field fieldno is indexed, and the tuple itself stores offset to the field in its own small field map, used by indexes. vdbe_field_ref then uses that map to retrieve offset value without decoding anything. But when SQL requests any field > fieldno, then vdbe_field_ref decodes the tuple from the beginning in the worst case. Even having previously accessed fieldno. But it could start decoding from the latter. An updated vdbe_field_ref fetcher class uses a bitmask of initialized slots to use pre-calculated offsets when possible. This speed-ups SQL in some corner case and doesn't damage performance in general scenarios. Closes #4267
Showing
- src/box/column_mask.h 27 additions, 0 deletionssrc/box/column_mask.h
- src/box/sql.c 4 additions, 1 deletionsrc/box/sql.c
- src/box/sql.h 6 additions, 3 deletionssrc/box/sql.h
- src/box/sql/vdbe.c 66 additions, 50 deletionssrc/box/sql/vdbe.c
- test/sql/misc.result 67 additions, 0 deletionstest/sql/misc.result
- test/sql/misc.test.lua 29 additions, 0 deletionstest/sql/misc.test.lua
Loading
Please register or sign in to comment