diff options
| author | Simon Riggs | 2018-03-27 18:57:02 +0000 |
|---|---|---|
| committer | Simon Riggs | 2018-03-27 18:57:02 +0000 |
| commit | c203d6cf81b4d7e43edb2b75ec1b741ba48e04e0 (patch) | |
| tree | cf9e4a14290ef99232a5f5f477d5b2672df57629 /src/include | |
| parent | 1944cdc98273dbb8439ad9b387ca2858531afcf0 (diff) | |
Allow HOT updates for some expression indexes
If the value of an index expression is unchanged after UPDATE,
allow HOT updates where previously we disallowed them, giving
a significant performance boost in those cases.
Particularly useful for indexes such as JSON->>field where the
JSON value changes but the indexed value does not.
Submitted as "surjective indexes" patch, now enabled by use
of new "recheck_on_update" parameter.
Author: Konstantin Knizhnik
Reviewer: Simon Riggs, with much wordsmithing and some cleanup
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/reloptions.h | 2 | ||||
| -rw-r--r-- | src/include/utils/rel.h | 12 | ||||
| -rw-r--r-- | src/include/utils/relcache.h | 3 |
3 files changed, 15 insertions, 2 deletions
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h index b32c1e9efe5..ef09611e0d6 100644 --- a/src/include/access/reloptions.h +++ b/src/include/access/reloptions.h @@ -51,6 +51,7 @@ typedef enum relopt_kind RELOPT_KIND_PARTITIONED = (1 << 11), /* if you add a new kind, make sure you update "last_default" too */ RELOPT_KIND_LAST_DEFAULT = RELOPT_KIND_PARTITIONED, + RELOPT_KIND_INDEX = RELOPT_KIND_BTREE|RELOPT_KIND_HASH|RELOPT_KIND_GIN|RELOPT_KIND_SPGIST, /* some compilers treat enums as signed ints, so we can't use 1 << 31 */ RELOPT_KIND_MAX = (1 << 30) } relopt_kind; @@ -276,6 +277,7 @@ extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate); extern bytea *view_reloptions(Datum reloptions, bool validate); extern bytea *index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate); +extern bytea *index_generic_reloptions(Datum reloptions, bool validate); extern bytea *attribute_reloptions(Datum reloptions, bool validate); extern bytea *tablespace_reloptions(Datum reloptions, bool validate); extern LOCKMODE AlterTableGetRelOptionsLockLevel(List *defList); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index aa8add544a1..c26c395b0bd 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -141,10 +141,12 @@ typedef struct RelationData List *rd_statlist; /* list of OIDs of extended stats */ /* data managed by RelationGetIndexAttrBitmap: */ - Bitmapset *rd_indexattr; /* identifies columns used in indexes */ + Bitmapset *rd_indexattr; /* columns used in non-projection indexes */ + Bitmapset *rd_projindexattr; /* columns used in projection indexes */ Bitmapset *rd_keyattr; /* cols that can be ref'd by foreign keys */ Bitmapset *rd_pkattr; /* cols included in primary key */ Bitmapset *rd_idattr; /* included in replica identity index */ + Bitmapset *rd_projidx; /* Oids of projection indexes */ PublicationActions *rd_pubactions; /* publication actions */ @@ -245,6 +247,14 @@ typedef struct ForeignKeyCacheInfo Oid conpfeqop[INDEX_MAX_KEYS]; /* PK = FK operator OIDs */ } ForeignKeyCacheInfo; +/* + * Options common for all all indexes + */ +typedef struct GenericIndexOpts +{ + int32 vl_len_; + bool recheck_on_update; +} GenericIndexOpts; /* * StdRdOptions diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index 8a546aba283..dbbf41b0c16 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -53,7 +53,8 @@ extern List *RelationGetIndexPredicate(Relation relation); typedef enum IndexAttrBitmapKind { - INDEX_ATTR_BITMAP_ALL, + INDEX_ATTR_BITMAP_HOT, + INDEX_ATTR_BITMAP_PROJ, INDEX_ATTR_BITMAP_KEY, INDEX_ATTR_BITMAP_PRIMARY_KEY, INDEX_ATTR_BITMAP_IDENTITY_KEY |
