Some questions about gin index

Andy Fan <zhihuifan1213@163.com>

From: Andy Fan <zhihuifan1213@163.com>
To: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-06-04T12:10:06Z
Lists: pgsql-hackers
Hi,

When reading the code for Gin Index, there are lots of confusion about
some concepts, so here are some questions in my mind.


1. search mode.

/*
 * searchMode settings for extractQueryFn.
 */
#define GIN_SEARCH_MODE_DEFAULT			0
#define GIN_SEARCH_MODE_INCLUDE_EMPTY	1
#define GIN_SEARCH_MODE_ALL				2
#define GIN_SEARCH_MODE_EVERYTHING		3	/* for internal use only */


2. 

typedef struct GinScanEntryData
{
..
	bool		isPartialMatch;
..
}


3. requiredEntries / additionalEntries

typedef struct GinScanKeyData
{
	/*
	 * At least one of the entries in requiredEntries must be present for a
	 * tuple to match the overall qual.
	 *
	 * additionalEntries contains entries that are needed by the consistent
	 * function to decide if an item matches, but are not sufficient to
	 * satisfy the qual without entries from requiredEntries.
	 */
	GinScanEntry *requiredEntries;
	int			nrequired;
	GinScanEntry *additionalEntries;
	int			nadditional;
 ..
}

For all the 3 questions, the general question is what is X and how does
it play its role? I have read the gin/README before asking, so any help
is appreciated.


-- 
Best Regards
Andy Fan