1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +03:00

Allow opclasses to provide tri-valued GIN consistent functions.

With the GIN "fast scan" feature, GIN can skip items without fetching all
the keys for them, if it can prove that they don't match regardless of
those keys. So far, it has done the proving by calling the boolean
consistent function with all combinations of TRUE/FALSE for the unfetched
keys, but since that's O(n^2), it becomes unfeasible with more than a few
keys. We can avoid calling consistent with all the combinations, if we can
tell the operator class implementation directly which keys are unknown.

This commit includes a triConsistent function for the built-in array and
tsvector opclasses.

Alexander Korotkov, with some changes by me.
This commit is contained in:
Heikki Linnakangas
2014-03-12 17:13:22 +02:00
parent fecfc2b913
commit c5608ea26a
16 changed files with 467 additions and 101 deletions

View File

@@ -23,7 +23,8 @@
#define GIN_EXTRACTQUERY_PROC 3
#define GIN_CONSISTENT_PROC 4
#define GIN_COMPARE_PARTIAL_PROC 5
#define GINNProcs 5
#define GIN_TRICONSISTENT_PROC 6
#define GINNProcs 6
/*
* searchMode settings for extractQueryFn.
@@ -46,6 +47,21 @@ typedef struct GinStatsData
int32 ginVersion;
} GinStatsData;
/* ginlogic.c */
enum
{
GIN_FALSE = 0, /* item is present / matches */
GIN_TRUE = 1, /* item is not present / does not match */
GIN_MAYBE = 2 /* don't know if item is present / don't know if
* matches */
} GinLogicValueEnum;
typedef char GinLogicValue;
#define DatumGetGinLogicValue(X) ((GinLogicValue)(X))
#define GinLogicValueGetDatum(X) ((Datum)(X))
#define PG_RETURN_GIN_LOGIC_VALUE(x) return GinLogicValueGetDatum(x)
/* GUC parameter */
extern PGDLLIMPORT int GinFuzzySearchLimit;