Skip to content

Commit 5827078

Browse files
author
Artur Zakirov
committed
Use ItemPointer comparison in comparetup_rum() only in full-scan
1 parent 48aae44 commit 5827078

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

rumget.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,10 @@ rumgettuple(IndexScanDesc scan, ScanDirection direction)
25342534
so->tbm = NULL;
25352535
so->entriesIncrIndex = -1;
25362536
so->firstCall = false;
2537-
so->sortstate = rum_tuplesort_begin_rum(work_mem, so->norderbys, false);
2537+
so->sortstate = rum_tuplesort_begin_rum(work_mem, so->norderbys, false,
2538+
so->totalentries > 0 &&
2539+
so->entries[0]->queryCategory == RUM_CAT_EMPTY_QUERY &&
2540+
so->entries[0]->scanWithAddInfo);
25382541

25392542
scanPendingInsert(scan);
25402543

rumsort.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ struct Tuplesortstate
405405

406406
bool reverse;
407407

408+
/* Do we need ItemPointer comparison in comparetup_rum()? */
409+
bool compareItemPointer;
410+
408411
/*
409412
* Resource snapshot for time of sort start.
410413
*/
@@ -1124,7 +1127,8 @@ rum_tuplesort_begin_index_hash(Relation heapRel,
11241127
}
11251128

11261129
Tuplesortstate *
1127-
rum_tuplesort_begin_rum(int workMem, int nKeys, bool randomAccess)
1130+
rum_tuplesort_begin_rum(int workMem, int nKeys, bool randomAccess,
1131+
bool compareItemPointer)
11281132
{
11291133
Tuplesortstate *state = rum_tuplesort_begin_common(workMem, randomAccess);
11301134
MemoryContext oldcontext;
@@ -1152,6 +1156,7 @@ rum_tuplesort_begin_rum(int workMem, int nKeys, bool randomAccess)
11521156
state->readtup = readtup_rum;
11531157
state->reversedirection = reversedirection_rum;
11541158
state->reverse = false;
1159+
state->compareItemPointer = compareItemPointer;
11551160

11561161
MemoryContextSwitchTo(oldcontext);
11571162

@@ -3865,6 +3870,9 @@ comparetup_rum(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
38653870
return 1;
38663871
}
38673872

3873+
if (!state->compareItemPointer)
3874+
return 0;
3875+
38683876
/*
38693877
* If key values are equal, we sort on ItemPointer.
38703878
*/

rumsort.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ extern Tuplesortstate *rum_tuplesort_begin_datum(Oid datumType,
8989
bool nullsFirstFlag,
9090
int workMem, bool randomAccess);
9191
extern Tuplesortstate *rum_tuplesort_begin_rum(int workMem,
92-
int nKeys, bool randomAccess);
92+
int nKeys, bool randomAccess, bool compareItemPointer);
9393

9494
extern void rum_tuplesort_set_bound(Tuplesortstate *state, int64 bound);
9595

0 commit comments

Comments
 (0)