aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/sort/tuplesort.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/sort/tuplesort.c')
-rw-r--r--src/backend/utils/sort/tuplesort.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index b17347b2141..9f1df874389 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -975,6 +975,7 @@ tuplesort_begin_cluster(TupleDesc tupDesc,
{
Tuplesortstate *state = tuplesort_begin_common(workMem, coordinate,
randomAccess);
+ AttrNumber leading;
BTScanInsert indexScanKey;
MemoryContext oldcontext;
int i;
@@ -1007,6 +1008,7 @@ tuplesort_begin_cluster(TupleDesc tupDesc,
state->abbrevNext = 10;
state->indexInfo = BuildIndexInfo(indexRel);
+ leading = state->indexInfo->ii_IndexAttrNumbers[0];
state->tupDesc = tupDesc; /* assume we need not copy tupDesc */
@@ -1045,7 +1047,7 @@ tuplesort_begin_cluster(TupleDesc tupDesc,
(scanKey->sk_flags & SK_BT_NULLS_FIRST) != 0;
sortKey->ssup_attno = scanKey->sk_attno;
/* Convey if abbreviation optimization is applicable in principle */
- sortKey->abbreviate = (i == 0);
+ sortKey->abbreviate = (i == 0 && leading != 0);
AssertState(sortKey->ssup_attno != 0);