Check the key gistindex_keytest() – does this index tuple satisfy the scan key(s)?
Scan all items on the GiST index page and insert them into the queue (or directly to output areas)
plain scan
Heap tuple TIDs are returned into so->pageData[]
ordered scan
Heap tuple TIDs are pushed into individual search queue items
If the fetch() is specified by the developer, then using it, algorithm can retrieve the data directly to output areas at this stage, without reference to the heap.
I think there are following changes to be made to GiST code:
1) When next consistent IndexTuple is found extract original Datums using "fetch" method.
2) Put those original Datums to queue.
3) When returning next ItemPointer from queue put original Datums to IndexScanDesc (into xs_itup).
3. Create function gistcanreturn to check whether fetch() is specified by user.
Amcanreturn – Function to check whether index supports index-only scans, or zero if none
There is the question of support index-only scans for multicolumn indexes. Probably it would require extend the interface to add separate columns checking.
To solve this question I need the community’s help.
4. Add details for index only scans into gistcostestimate function
Also, another part of work to be mentioned is to implement fetch function for all suitable opclasses.