skipscan_instrumentation.txt

text/plain

Filename: skipscan_instrumentation.txt
Type: text/plain
Part: 0
Message: Re: Index Searches higher than expected for skip scan
pg@regression:5432 [1116003]=# SELECT boolean_field FROM example WHERE integer_field = 5432;
LOG:
๐Ÿ‘พ  btbeginscan to begin scan of index "bool_int_idx" in worker -1
โ™ป๏ธ  btrescan
btrescan: BTScanPosInvalidate() called for markPos
_bt_preprocess_keys:  scan->keyData[0]: [ strategy: = , attno: 2/"integer_field", func: int84eq, flags: [] ]
_bt_preprocess_keys:    so->keyData[0]: [ strategy: = , attno: 1/"boolean_field", func: booleq, flags: [SK_SEARCHARRAY, SK_BT_REQFWD, SK_BT_REQBKWD, SK_BT_SKIP] ]
                        so->keyData[1]: [ strategy: = , attno: 2/"integer_field", func: int84eq, flags: [SK_BT_REQFWD, SK_BT_REQBKWD] ]
_bt_preprocess_keys: scan->numberOfKeys is 1, so->numberOfKeys on output is 2, so->numArrayKeys on output is 1

โž•     โž•     โž•
_bt_first: sk could not be formed, so descending to leftmost leaf page in whole index
_bt_readpage: ๐Ÿ€  1 with 122 offsets/tuples (leftsib 0, rightsib 2) โžก๏ธ
 _bt_readpage first: (boolean_field, integer_field)=(f, 0), TID='(171,68)', 0x7fffaeaa9fc8, from non-pivot offnum 2 started page
 _bt_readpage pstate.startikey: 0, with 2 scan keys
  _bt_checkkeys: comparing (boolean_field, integer_field)=(f, 0) with TID (171,68), 0x7fffaeaa9fc8
_bt_advance_array_keys, sktrig (required): 0, tuple: (boolean_field, integer_field)=(f, 0), 0x7fffaeaa9fc8

  - sk: 0, sk_attno: 1, cur_elem:   -1, num_elems:   -1, val: ????? SK_BT_MINVAL            <--

  + sk: 0, sk_attno: 1, cur_elem:   -1, num_elems:   -1, val: f

 _bt_readpage final: (boolean_field, integer_field)=(f, 0), TID='(171,68)', 0x7fffaeaa9fc8, from non-pivot offnum 2 set so->currPos.moreRight=false โžก๏ธ  ๐Ÿ›‘
 _bt_readpage stats: currPos.firstItem: 0, currPos.lastItem: -1, nmatching: 0 โŒ

โž•     โž•     โž•
_bt_first: sk_attno 1. val: f, func: btboolcmp, flags: [SK_SEARCHARRAY, SK_BT_REQFWD, SK_BT_REQBKWD, SK_BT_SKIP]
           sk_attno 2. val: 5432, func: btint84cmp, flags: [SK_BT_REQFWD, SK_BT_REQBKWD]
           with strat_total='= ', inskey.keys=2, inskey.nextkey=0, inskey.backward=0
๐Ÿ”ฝ  ==================== _bt_search begin at root 3 level 1 ====================
_bt_moveright: blk 3 is rightmost
_bt_search: sk > (boolean_field, integer_field)=(f, 5321), sk <= (boolean_field, integer_field)=(f, 5443)
๐Ÿ”ฝ  -------------------- descended to child blk 46 level 0 --------------------
_bt_moveright: (boolean_field, integer_field)=(f, 5443), high key no move right
โน๏ธ ==================== _bt_search end ==================== โžก๏ธ
_bt_readpage: ๐Ÿ€  46 with 123 offsets/tuples (leftsib 45, rightsib 47) โžก๏ธ
 _bt_readpage first: (boolean_field, integer_field)=(f, 5432), TID='(5,40)', 0x7fffaeaae770, from non-pivot offnum 113 started page
 _bt_readpage pstate.startikey: 0, with 2 scan keys
  _bt_checkkeys: comparing (boolean_field, integer_field)=(f, 5432) with TID (5,40), 0x7fffaeaae770
  _bt_checkkeys: comparing (boolean_field, integer_field)=(f, 5433) with TID (68,20), 0x7fffaeaae758
_bt_advance_array_keys, sktrig (required): 1, tuple: (boolean_field, integer_field)=(f, 5433), 0x7fffaeaae758

  - sk: 0, sk_attno: 1, cur_elem:   -1, num_elems:   -1, val: f

  + sk: 0, sk_attno: 1, cur_elem:   -1, num_elems:   -1, val: t

 _bt_readpage final: (boolean_field, integer_field)=(f, 5433), TID='(68,20)', 0x7fffaeaae758, from non-pivot offnum 114 set so->currPos.moreRight=false โžก๏ธ  ๐Ÿ›‘
 _bt_readpage stats: currPos.firstItem: 0, currPos.lastItem: 4, nmatching: 5 โœ…

โž•     โž•     โž•
_bt_first: sk_attno 1. val: t, func: btboolcmp, flags: [SK_SEARCHARRAY, SK_BT_REQFWD, SK_BT_REQBKWD, SK_BT_SKIP]
           sk_attno 2. val: 5432, func: btint84cmp, flags: [SK_BT_REQFWD, SK_BT_REQBKWD]
           with strat_total='= ', inskey.keys=2, inskey.nextkey=0, inskey.backward=0
๐Ÿ”ฝ  ==================== _bt_search begin at root 3 level 1 ====================
_bt_moveright: blk 3 is rightmost
_bt_search: sk > (boolean_field, integer_field)=(t, 5357), sk <= (boolean_field, integer_field)=(t, 5481)
๐Ÿ”ฝ  -------------------- descended to child blk 129 level 0 --------------------
_bt_moveright: (boolean_field, integer_field)=(t, 5481), high key no move right
โน๏ธ ==================== _bt_search end ==================== โžก๏ธ
_bt_readpage: ๐Ÿ€  129 with 125 offsets/tuples (leftsib 128, rightsib 130) โžก๏ธ
 _bt_readpage first: (boolean_field, integer_field)=(t, 5432), TID='(277,111)', 0x7fffaeab0fb0, from non-pivot offnum 77 started page
 _bt_readpage pstate.startikey: 0, with 2 scan keys
  _bt_checkkeys: comparing (boolean_field, integer_field)=(t, 5432) with TID (277,111), 0x7fffaeab0fb0
  _bt_checkkeys: comparing (boolean_field, integer_field)=(t, 5433) with TID (54,172), 0x7fffaeab0f78
_bt_advance_array_keys, sktrig (required): 1, tuple: (boolean_field, integer_field)=(t, 5433), 0x7fffaeab0f78

  - sk: 0, sk_attno: 1, cur_elem:   -1, num_elems:   -1, val: t

  + sk: 0, sk_attno: 1, cur_elem:   -1, num_elems:   -1, val: SK_ISNULL

 _bt_readpage final: (boolean_field, integer_field)=(t, 5433), TID='(54,172)', 0x7fffaeab0f78, from non-pivot offnum 78 set so->currPos.moreRight=false โžก๏ธ  ๐Ÿ›‘
 _bt_readpage stats: currPos.firstItem: 0, currPos.lastItem: 0, nmatching: 1 โœ…

โž•     โž•     โž•
_bt_first: sk_attno 1. val: NULL, flags: [SK_ISNULL, SK_SEARCHARRAY, SK_SEARCHNULL, SK_BT_REQFWD, SK_BT_REQBKWD, SK_BT_SKIP]
           sk_attno 2. val: 5432, func: btint84cmp, flags: [SK_BT_REQFWD, SK_BT_REQBKWD]
           with strat_total='= ', inskey.keys=2, inskey.nextkey=0, inskey.backward=0
๐Ÿ”ฝ  ==================== _bt_search begin at root 3 level 1 ====================
_bt_moveright: blk 3 is rightmost
_bt_search: sk > (boolean_field, integer_field)=(t, 9973), sk <= (boolean_field, integer_field)=() , (<= separator is high key)
๐Ÿ”ฝ  -------------------- descended to child blk 167 level 0 --------------------
_bt_moveright: blk 167 is rightmost
โน๏ธ ==================== _bt_search end ==================== โžก๏ธ
_bt_readpage: ๐Ÿ€  167 with 28 offsets/tuples (leftsib 166, rightsib 0) โžก๏ธ
 _bt_readpage first: none, offnum 29 is > maxoff of 28
 _bt_readpage final:  , (nil), continuescan high key check not performed on rightmost page โžก๏ธ  ๐Ÿ›‘
 _bt_readpage stats: currPos.firstItem: 0, currPos.lastItem: -1, nmatching: 0 โŒ
btendscan for index "bool_int_idx", ParallelWorkerNumber: -1, npages: 4, nforcenonrequiredpages: 0, nwrongprecheckpages: 0, nsearches: 4

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ boolean_field โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ f             โ”‚
โ”‚ f             โ”‚
โ”‚ f             โ”‚
โ”‚ f             โ”‚
โ”‚ f             โ”‚
โ”‚ t             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
(6 rows)