From 77039ca4137c56628e7b0d6627792fd21290959d Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Fri, 28 Apr 2023 16:27:07 -0400 Subject: [PATCH] configurable import batch size --- CRM/Admin/Form/Setting/Miscellaneous.php | 2 ++ CRM/Import/Parser.php | 2 +- settings/Core.setting.php | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index 722fef9cda..51ddc220e6 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -42,6 +42,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'remote_profile_submissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'allow_alert_autodismissal' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'prevNextBackend' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, + 'import_batch_size' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, ]; /** @@ -62,6 +63,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'recentItemsProviders', 'dedupe_default_limit', 'prevNextBackend', + 'import_batch_size', ]); } diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 05a6c65aed..bfce7cdaef 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -672,7 +672,7 @@ abstract class CRM_Import_Parser implements UserJobInterface { $queue = Civi::queue('user_job_' . $this->getUserJobID(), ['type' => 'Sql', 'error' => 'abort', 'runner' => 'task', 'user_job_id' => $this->getUserJobID(), 'retry_limit' => 5]); UserJob::update(FALSE)->setValues(['queue_id.name' => 'user_job_' . $this->getUserJobID()])->addWhere('id', '=', $this->getUserJobID())->execute(); $offset = 0; - $batchSize = 50; + $batchSize = Civi::settings()->get('import_batch_size'); while ($totalRows > 0) { if ($totalRows < $batchSize) { $batchSize = $totalRows; diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 42d90b7c7c..f0db59869d 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -1006,6 +1006,24 @@ return [ 'callback' => 'CRM_Utils_Recent::getProviders', ], ], + 'import_batch_size' => [ + 'name' => 'import_batch_size', + 'type' => 'Integer', + 'default' => 50, + 'quick_form_type' => 'Element', + 'html_type' => 'text', + 'html_attributes' => [ + 'size' => 2, + 'maxlength' => 3, + ], + 'add' => '5.62', + 'title' => ts('Import Batch Size'), + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => ts('Number of records to process at once during import.'), + 'help_text' => ts('If your imports time out, reduce this number. You can increase it for better import performance on servers with longer timeouts.'), + 'settings_pages' => 'misc', + ], 'dedupe_default_limit' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', -- 2.25.1