Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9dc718b

Browse files
Pass down "logically unchanged index" hint.
Add an executor aminsert() hint mechanism that informs index AMs thatthe incoming index tuple (the tuple that accompanies the hint) is notbeing inserted by execution of an SQL statement that logically modifiesany of the index's key columns.The hint is received by indexes when an UPDATE takes place that does notapply an optimization like heapam's HOT (though only for indexes whereall key columns are logically unchanged). Any index tuple that receivesthe hint on insert is expected to be a duplicate of at least oneexisting older version that is needed for the same logical row. Relatedversions will typically be stored on the same index page, at leastwithin index AMs that apply the hint.Recognizing the difference between MVCC version churn duplicates andtrue logical row duplicates at the index AM level can help with cleanupof garbage index tuples. Cleanup can intelligently target tuples thatare likely to be garbage, without wasting too many cycles on lesspromising tuples/pages (index pages with little or no version churn).This is infrastructure for an upcoming commit that will teach nbtree toperform bottom-up index deletion. No index AM actually applies the hintjust yet.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Victor Yegorov <vyegorov@gmail.com>Discussion:https://postgr.es/m/CAH2-Wz=CEKFa74EScx_hFVshCOn6AA5T-ajFASTdzipdkLTNQQ@mail.gmail.com
1 parent39b0369 commit9dc718b

File tree

31 files changed

+214
-25
lines changed

31 files changed

+214
-25
lines changed

‎contrib/bloom/blinsert.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ bool
198198
blinsert(Relationindex,Datum*values,bool*isnull,
199199
ItemPointerht_ctid,RelationheapRel,
200200
IndexUniqueCheckcheckUnique,
201+
boolindexUnchanged,
201202
IndexInfo*indexInfo)
202203
{
203204
BloomStateblstate;

‎contrib/bloom/bloom.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ extern bool blvalidate(Oid opclassoid);
192192
externboolblinsert(Relationindex,Datum*values,bool*isnull,
193193
ItemPointerht_ctid,RelationheapRel,
194194
IndexUniqueCheckcheckUnique,
195+
boolindexUnchanged,
195196
structIndexInfo*indexInfo);
196197
externIndexScanDescblbeginscan(Relationr,intnkeys,intnorderbys);
197198
externint64blgetbitmap(IndexScanDescscan,TIDBitmap*tbm);

‎doc/src/sgml/indexam.sgml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ aminsert (Relation indexRelation,
293293
ItemPointer heap_tid,
294294
Relation heapRelation,
295295
IndexUniqueCheck checkUnique,
296+
bool indexUnchanged,
296297
IndexInfo *indexInfo);
297298
</programlisting>
298299
Insert a new tuple into an existing index. The <literal>values</literal> and
@@ -308,6 +309,20 @@ aminsert (Relation indexRelation,
308309
look into the heap to verify tuple liveness).
309310
</para>
310311

312+
<para>
313+
The <literal>indexUnchanged</literal> boolean value gives a hint
314+
about the nature of the tuple to be indexed. When it is true,
315+
the tuple is a duplicate of some existing tuple in the index. The
316+
new tuple is a logically unchanged successor MVCC tuple version. This
317+
happens when an <command>UPDATE</command> takes place that does not
318+
modify any columns covered by the index, but nevertheless requires a
319+
new version in the index. The index AM may use this hint to decide
320+
to apply bottom-up index deletion in parts of the index where many
321+
versions of the same logical row accumulate. Note that updating a
322+
non-key column does not affect the value of
323+
<literal>indexUnchanged</literal>.
324+
</para>
325+
311326
<para>
312327
The function's Boolean result value is significant only when
313328
<literal>checkUnique</literal> is <literal>UNIQUE_CHECK_PARTIAL</literal>.

‎src/backend/access/brin/brin.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ bool
151151
brininsert(RelationidxRel,Datum*values,bool*nulls,
152152
ItemPointerheaptid,RelationheapRel,
153153
IndexUniqueCheckcheckUnique,
154+
boolindexUnchanged,
154155
IndexInfo*indexInfo)
155156
{
156157
BlockNumberpagesPerRange;

‎src/backend/access/common/toast_internals.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ toast_save_datum(Relation rel, Datum value,
328328
toastrel,
329329
toastidxs[i]->rd_index->indisunique ?
330330
UNIQUE_CHECK_YES :UNIQUE_CHECK_NO,
331-
NULL);
331+
false,NULL);
332332
}
333333

334334
/*

‎src/backend/access/gin/gininsert.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ bool
488488
gininsert(Relationindex,Datum*values,bool*isnull,
489489
ItemPointerht_ctid,RelationheapRel,
490490
IndexUniqueCheckcheckUnique,
491+
boolindexUnchanged,
491492
IndexInfo*indexInfo)
492493
{
493494
GinState*ginstate= (GinState*)indexInfo->ii_AmCache;

‎src/backend/access/gist/gist.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ bool
156156
gistinsert(Relationr,Datum*values,bool*isnull,
157157
ItemPointerht_ctid,RelationheapRel,
158158
IndexUniqueCheckcheckUnique,
159+
boolindexUnchanged,
159160
IndexInfo*indexInfo)
160161
{
161162
GISTSTATE*giststate= (GISTSTATE*)indexInfo->ii_AmCache;

‎src/backend/access/hash/hash.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ bool
247247
hashinsert(Relationrel,Datum*values,bool*isnull,
248248
ItemPointerht_ctid,RelationheapRel,
249249
IndexUniqueCheckcheckUnique,
250+
boolindexUnchanged,
250251
IndexInfo*indexInfo)
251252
{
252253
Datumindex_values[1];

‎src/backend/access/heap/heapam_handler.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,7 @@ heapam_index_validate_scan(Relation heapRelation,
19561956
heapRelation,
19571957
indexInfo->ii_Unique ?
19581958
UNIQUE_CHECK_YES :UNIQUE_CHECK_NO,
1959+
false,
19591960
indexInfo);
19601961

19611962
state->tups_inserted+=1;

‎src/backend/access/index/indexam.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ index_insert(Relation indexRelation,
179179
ItemPointerheap_t_ctid,
180180
RelationheapRelation,
181181
IndexUniqueCheckcheckUnique,
182+
boolindexUnchanged,
182183
IndexInfo*indexInfo)
183184
{
184185
RELATION_CHECKS;
@@ -191,7 +192,8 @@ index_insert(Relation indexRelation,
191192

192193
returnindexRelation->rd_indam->aminsert(indexRelation,values,isnull,
193194
heap_t_ctid,heapRelation,
194-
checkUnique,indexInfo);
195+
checkUnique,indexUnchanged,
196+
indexInfo);
195197
}
196198

197199
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp