From 7cba6c16710a98061aa0ff6e771ee4be6a96bdc7 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Mon, 2 Jul 2018 01:15:49 +0200 Subject: [PATCH] MDL-60915 core_dml: Change behavior to disabled by default In stables it was decided to keep the current behavior (not buffering/cursors) so nothing breaks/changes suddenly. So this commit just disables the default buffer size used in Moodle 3.5 and up (100000), defaulting to zero (feature disabled). Still the feature can be enabled via dboptions and it's docummented in the config-dist file. --- config-dist.php | 15 +++++++++------ lib/dml/pgsql_native_moodle_database.php | 5 +---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config-dist.php b/config-dist.php index 5308052c915..0803045c7a7 100644 --- a/config-dist.php +++ b/config-dist.php @@ -73,12 +73,15 @@ $CFG->dboptions = array( // 'fetchbuffersize' => 100000, // On PostgreSQL, this option sets a limit // on the number of rows that are fetched into // memory when doing a large recordset query - // (e.g. search indexing). Default is 100000. - // Uncomment and set to a value to change it, - // or zero to turn off the limit. You need to - // set to zero if you are using pg_bouncer in - // 'transaction' mode (it is fine in 'session' - // mode). + // (e.g. search indexing). + // By default, this feature is disabled in + // Moodle 3.4, using a value of zero. In Moodle + // 3.5 and up the feature is enabled by default + // with a buffer size of 100000. + // Uncomment and set a positive value to enable it, + // noting that you need to keep it to zero + // if you are using pg_bouncer in 'transaction' + // mode (it is fine in 'session' mode). ); diff --git a/lib/dml/pgsql_native_moodle_database.php b/lib/dml/pgsql_native_moodle_database.php index ae7550175e4..7e87010556e 100644 --- a/lib/dml/pgsql_native_moodle_database.php +++ b/lib/dml/pgsql_native_moodle_database.php @@ -48,9 +48,6 @@ class pgsql_native_moodle_database extends moodle_database { /** @var int Number of cursors used (for constructing a unique ID) */ protected $cursorcount = 0; - /** @var int Default number of rows to fetch at a time when using recordsets with cursors */ - const DEFAULT_FETCH_BUFFER_SIZE = 100000; - /** * Detects if all needed PHP stuff installed. * Note: can be used before connect() @@ -782,7 +779,7 @@ class pgsql_native_moodle_database extends moodle_database { if (array_key_exists('fetchbuffersize', $this->dboptions)) { return (int)$this->dboptions['fetchbuffersize']; } else { - return self::DEFAULT_FETCH_BUFFER_SIZE; + return 0; // Disabled by default. } }