mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
Add a GUC variable "synchronize_seqscans" to allow clients to disable the new
synchronized-scanning behavior, and make pg_dump disable sync scans so that it will reliably preserve row ordering. Per recent discussions.
This commit is contained in:
parent
6dfa40d69f
commit
47df4f6688
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.162 2008/01/27 19:12:28 tgl Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.163 2008/01/30 18:35:55 tgl Exp $ -->
|
||||||
|
|
||||||
<chapter Id="runtime-config">
|
<chapter Id="runtime-config">
|
||||||
<title>Server Configuration</title>
|
<title>Server Configuration</title>
|
||||||
@ -4611,6 +4611,28 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry id="guc-synchronize-seqscans" xreflabel="synchronize_seqscans">
|
||||||
|
<term><varname>synchronize_seqscans</varname> (<type>boolean</type>)</term>
|
||||||
|
<indexterm>
|
||||||
|
<primary><varname>synchronize_seqscans</> configuration parameter</primary>
|
||||||
|
</indexterm>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
This allows sequential scans of large tables to synchronize with each
|
||||||
|
other, so that concurrent scans read the same block at about the
|
||||||
|
same time and hence share the I/O workload. When this is enabled,
|
||||||
|
a scan might start in the middle of the table and then <quote>wrap
|
||||||
|
around</> the end to cover all rows, so as to synchronize with the
|
||||||
|
activity of scans already in progress. This can result in
|
||||||
|
unpredictable changes in the row ordering returned by queries that
|
||||||
|
have no <literal>ORDER BY</> clause. Setting this parameter to
|
||||||
|
<literal>off</> ensures the pre-8.3 behavior in which a sequential
|
||||||
|
scan always starts from the beginning of the table. The default
|
||||||
|
is <literal>on</>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.248 2008/01/14 01:39:09 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.249 2008/01/30 18:35:55 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -59,6 +59,10 @@
|
|||||||
#include "utils/syscache.h"
|
#include "utils/syscache.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* GUC variable */
|
||||||
|
bool synchronize_seqscans = true;
|
||||||
|
|
||||||
|
|
||||||
static HeapScanDesc heap_beginscan_internal(Relation relation,
|
static HeapScanDesc heap_beginscan_internal(Relation relation,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
int nkeys, ScanKey key,
|
int nkeys, ScanKey key,
|
||||||
@ -104,7 +108,8 @@ initscan(HeapScanDesc scan, ScanKey key)
|
|||||||
* the thresholds for these features could be different, we make them the
|
* the thresholds for these features could be different, we make them the
|
||||||
* same so that there are only two behaviors to tune rather than four.
|
* same so that there are only two behaviors to tune rather than four.
|
||||||
* (However, some callers need to be able to disable one or both of
|
* (However, some callers need to be able to disable one or both of
|
||||||
* these behaviors, independently of the size of the table.)
|
* these behaviors, independently of the size of the table; also there
|
||||||
|
* is a GUC variable that can disable synchronized scanning.)
|
||||||
*
|
*
|
||||||
* During a rescan, don't make a new strategy object if we don't have to.
|
* During a rescan, don't make a new strategy object if we don't have to.
|
||||||
*/
|
*/
|
||||||
@ -129,7 +134,7 @@ initscan(HeapScanDesc scan, ScanKey key)
|
|||||||
scan->rs_strategy = NULL;
|
scan->rs_strategy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allow_sync)
|
if (allow_sync && synchronize_seqscans)
|
||||||
{
|
{
|
||||||
scan->rs_syncscan = true;
|
scan->rs_syncscan = true;
|
||||||
scan->rs_startblock = ss_get_location(scan->rs_rd, scan->rs_nblocks);
|
scan->rs_startblock = ss_get_location(scan->rs_rd, scan->rs_nblocks);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.431 2008/01/27 19:12:28 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.432 2008/01/30 18:35:55 tgl Exp $
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------
|
*--------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -110,6 +110,7 @@ extern int CommitDelay;
|
|||||||
extern int CommitSiblings;
|
extern int CommitSiblings;
|
||||||
extern char *default_tablespace;
|
extern char *default_tablespace;
|
||||||
extern char *temp_tablespaces;
|
extern char *temp_tablespaces;
|
||||||
|
extern bool synchronize_seqscans;
|
||||||
extern bool fullPageWrites;
|
extern bool fullPageWrites;
|
||||||
|
|
||||||
#ifdef TRACE_SORT
|
#ifdef TRACE_SORT
|
||||||
@ -1052,6 +1053,15 @@ static struct config_bool ConfigureNamesBool[] =
|
|||||||
false, NULL, NULL
|
false, NULL, NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
{"synchronize_seqscans", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
|
||||||
|
gettext_noop("Enable synchronized sequential scans."),
|
||||||
|
NULL
|
||||||
|
},
|
||||||
|
&synchronize_seqscans,
|
||||||
|
true, NULL, NULL
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
{"archive_mode", PGC_POSTMASTER, WAL_SETTINGS,
|
{"archive_mode", PGC_POSTMASTER, WAL_SETTINGS,
|
||||||
gettext_noop("Allows archiving of WAL files using archive_command."),
|
gettext_noop("Allows archiving of WAL files using archive_command."),
|
||||||
|
@ -476,9 +476,10 @@
|
|||||||
#backslash_quote = safe_encoding # on, off, or safe_encoding
|
#backslash_quote = safe_encoding # on, off, or safe_encoding
|
||||||
#default_with_oids = off
|
#default_with_oids = off
|
||||||
#escape_string_warning = on
|
#escape_string_warning = on
|
||||||
#standard_conforming_strings = off
|
|
||||||
#regex_flavor = advanced # advanced, extended, or basic
|
#regex_flavor = advanced # advanced, extended, or basic
|
||||||
#sql_inheritance = on
|
#sql_inheritance = on
|
||||||
|
#standard_conforming_strings = off
|
||||||
|
#synchronize_seqscans = on
|
||||||
|
|
||||||
# - Other Platforms and Clients -
|
# - Other Platforms and Clients -
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* by PostgreSQL
|
* by PostgreSQL
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.481 2008/01/01 19:45:55 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.482 2008/01/30 18:35:55 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -552,6 +552,20 @@ main(int argc, char **argv)
|
|||||||
/* Set the datestyle to ISO to ensure the dump's portability */
|
/* Set the datestyle to ISO to ensure the dump's portability */
|
||||||
do_sql_command(g_conn, "SET DATESTYLE = ISO");
|
do_sql_command(g_conn, "SET DATESTYLE = ISO");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If supported, set extra_float_digits so that we can dump float data
|
||||||
|
* exactly (given correctly implemented float I/O code, anyway)
|
||||||
|
*/
|
||||||
|
if (g_fout->remoteVersion >= 70400)
|
||||||
|
do_sql_command(g_conn, "SET extra_float_digits TO 2");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If synchronized scanning is supported, disable it, to prevent
|
||||||
|
* unpredictable changes in row ordering across a dump and reload.
|
||||||
|
*/
|
||||||
|
if (g_fout->remoteVersion >= 80300)
|
||||||
|
do_sql_command(g_conn, "SET synchronize_seqscans TO off");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start serializable transaction to dump consistent data.
|
* Start serializable transaction to dump consistent data.
|
||||||
*/
|
*/
|
||||||
@ -567,13 +581,6 @@ main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
username_subquery = "SELECT usename FROM pg_user WHERE usesysid =";
|
username_subquery = "SELECT usename FROM pg_user WHERE usesysid =";
|
||||||
|
|
||||||
/*
|
|
||||||
* If supported, set extra_float_digits so that we can dump float data
|
|
||||||
* exactly (given correctly implemented float I/O code, anyway)
|
|
||||||
*/
|
|
||||||
if (g_fout->remoteVersion >= 70400)
|
|
||||||
do_sql_command(g_conn, "SET extra_float_digits TO 2");
|
|
||||||
|
|
||||||
/* Find the last built-in OID, if needed */
|
/* Find the last built-in OID, if needed */
|
||||||
if (g_fout->remoteVersion < 70300)
|
if (g_fout->remoteVersion < 70300)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user