Skip to content

Commit c8cd76d

Browse files
committed
Tweak trace_sort code to show the merge order (number of active input
tapes) for each merge step. This will give us some idea of how effective the merge distribution algorithm is.
1 parent d233ec2 commit c8cd76d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/backend/utils/sort/tuplesort.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
* Portions Copyright (c) 1994, Regents of the University of California
9292
*
9393
* IDENTIFICATION
94-
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.63 2006/03/07 19:06:50 tgl Exp $
94+
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.64 2006/03/08 16:59:03 tgl Exp $
9595
*
9696
*-------------------------------------------------------------------------
9797
*/
@@ -296,6 +296,7 @@ struct Tuplesortstate
296296
int *tp_runs; /* # of real runs on each tape */
297297
int *tp_dummy; /* # of dummy runs for each tape (D[]) */
298298
int *tp_tapenum; /* Actual tape numbers (TAPE[]) */
299+
int activeTapes; /* # of active input tapes in merge pass */
299300

300301
/*
301302
* These variables are used after completion of sorting to keep track of
@@ -943,9 +944,15 @@ tuplesort_performsort(Tuplesortstate *state)
943944

944945
#ifdef TRACE_SORT
945946
if (trace_sort)
946-
elog(LOG, "performsort done%s: %s",
947-
(state->status == TSS_FINALMERGE) ? " (except final merge)" : "",
948-
pg_rusage_show(&state->ru_start));
947+
{
948+
if (state->status == TSS_FINALMERGE)
949+
elog(LOG, "performsort done (except %d-way final merge): %s",
950+
state->activeTapes,
951+
pg_rusage_show(&state->ru_start));
952+
else
953+
elog(LOG, "performsort done: %s",
954+
pg_rusage_show(&state->ru_start));
955+
}
949956
#endif
950957

951958
MemoryContextSwitchTo(oldcontext);
@@ -1566,7 +1573,7 @@ mergeonerun(Tuplesortstate *state)
15661573

15671574
#ifdef TRACE_SORT
15681575
if (trace_sort)
1569-
elog(LOG, "finished merge step: %s",
1576+
elog(LOG, "finished %d-way merge step: %s", state->activeTapes,
15701577
pg_rusage_show(&state->ru_start));
15711578
#endif
15721579
}
@@ -1614,6 +1621,7 @@ beginmerge(Tuplesortstate *state)
16141621
activeTapes++;
16151622
}
16161623
}
1624+
state->activeTapes = activeTapes;
16171625

16181626
/*
16191627
* Initialize space allocation to let each active input tape have an equal

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy