summaryrefslogtreecommitdiff
path: root/src/include/utils/tuplesort.h
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-08-29 13:22:49 -0400
committerRobert Haas <rhaas@postgresql.org>2017-08-29 13:26:33 -0400
commitbf11e7ee2e3607bb67d25aec73aa53b2d7e9961b (patch)
tree89c3d26f157949896e1a69c1ea4f4ae5b64833ee /src/include/utils/tuplesort.h
parent3452dc5240da43e833118484e1e9b4894d04431c (diff)
downloadpostgresql-bf11e7ee2e3607bb67d25aec73aa53b2d7e9961b.tar.gz
Propagate sort instrumentation from workers back to leader.
Up until now, when parallel query was used, no details about the sort method or space used by the workers were available; details were shown only for any sorting done by the leader. Fix that. Commit 1177ab1dabf72bafee8f19d904cee3a299f25892 forced the test case added by commit 1f6d515a67ec98194c23a5db25660856c9aab944 to run without parallelism; now that we have this infrastructure, allow that again, with a little tweaking to make it pass with and without force_parallel_mode. Robert Haas and Tom Lane Discussion: http://postgr.es/m/CA+Tgmoa2VBZW6S8AAXfhpHczb=Rf6RqQ2br+zJvEgwJ0uoD_tQ@mail.gmail.com
Diffstat (limited to 'src/include/utils/tuplesort.h')
-rw-r--r--src/include/utils/tuplesort.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index 28c168a801..b6b8c8ef8c 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -32,6 +32,34 @@
typedef struct Tuplesortstate Tuplesortstate;
/*
+ * Data structures for reporting sort statistics. Note that
+ * TuplesortInstrumentation can't contain any pointers because we
+ * sometimes put it in shared memory.
+ */
+typedef enum
+{
+ SORT_TYPE_STILL_IN_PROGRESS = 0,
+ SORT_TYPE_TOP_N_HEAPSORT,
+ SORT_TYPE_QUICKSORT,
+ SORT_TYPE_EXTERNAL_SORT,
+ SORT_TYPE_EXTERNAL_MERGE
+} TuplesortMethod;
+
+typedef enum
+{
+ SORT_SPACE_TYPE_DISK,
+ SORT_SPACE_TYPE_MEMORY
+} TuplesortSpaceType;
+
+typedef struct TuplesortInstrumentation
+{
+ TuplesortMethod sortMethod; /* sort algorithm used */
+ TuplesortSpaceType spaceType; /* type of space spaceUsed represents */
+ long spaceUsed; /* space consumption, in kB */
+} TuplesortInstrumentation;
+
+
+/*
* We provide multiple interfaces to what is essentially the same code,
* since different callers have different data to be sorted and want to
* specify the sort key information differently. There are two APIs for
@@ -107,9 +135,9 @@ extern bool tuplesort_skiptuples(Tuplesortstate *state, int64 ntuples,
extern void tuplesort_end(Tuplesortstate *state);
extern void tuplesort_get_stats(Tuplesortstate *state,
- const char **sortMethod,
- const char **spaceType,
- long *spaceUsed);
+ TuplesortInstrumentation *stats);
+extern const char *tuplesort_method_name(TuplesortMethod m);
+extern const char *tuplesort_space_type_name(TuplesortSpaceType t);
extern int tuplesort_merge_order(int64 allowedMem);