diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-04-08 02:36:26 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-04-08 02:36:26 -0400 |
commit | 0711803775a37e0bf39d7efdd1e34d9d7e640ea1 (patch) | |
tree | 8f9e68f32ace8aa5ca7520f7589aca419266b0ce /src/backend/utils/misc | |
parent | 719c84c1be51f3d3fe6049b77ddbaa0c4b58a9a9 (diff) | |
download | postgresql-0711803775a37e0bf39d7efdd1e34d9d7e640ea1.tar.gz postgresql-0711803775a37e0bf39d7efdd1e34d9d7e640ea1.zip |
Use quicksort, not replacement selection, for external sorting.
We still use replacement selection for the first run of the sort only
and only when the number of tuples is relatively small. Otherwise,
the first run, and subsequent runs in all cases, are produced using
quicksort. This tends to be faster except perhaps for very small
amounts of working memory.
Peter Geoghegan, reviewed by Tomas Vondra, Jeff Janes, Mithun Cy,
Greg Stark, and me.
Diffstat (limited to 'src/backend/utils/misc')
-rw-r--r-- | src/backend/utils/misc/guc.c | 10 | ||||
-rw-r--r-- | src/backend/utils/misc/postgresql.conf.sample | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index a07050017ee..f7ed167d7f8 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1928,6 +1928,16 @@ static struct config_int ConfigureNamesInt[] = NULL, NULL, NULL }, + { + {"replacement_sort_tuples", PGC_USERSET, RESOURCES_MEM, + gettext_noop("Sets the maximum number of tuples to be sorted using replacement selection."), + gettext_noop("When more tuples than this are present, quicksort will be used.") + }, + &replacement_sort_tuples, + 150000, 0, INT_MAX, + NULL, NULL, NULL + }, + /* * We use the hopefully-safely-small value of 100kB as the compiled-in * default for max_stack_depth. InitializeGUCOptions will increase it if diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 8da3ff14c66..bcc86e29d27 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -125,6 +125,7 @@ # actively intend to use prepared transactions. #work_mem = 4MB # min 64kB #maintenance_work_mem = 64MB # min 1MB +#replacement_sort_tuples = 150000 # limits use of replacement selection sort #autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem #max_stack_depth = 2MB # min 100kB #dynamic_shared_memory_type = posix # the default is the first option |