From 5f12cba7e1ddd99a1e02f82b053b67001f5882c4 Mon Sep 17 00:00:00 2001 From: Krzysztof Ruszczynski Date: Wed, 9 Apr 2025 12:53:53 +0200 Subject: [PATCH] Performance fix: removing unnecessary sql queries checking if selected options exist (final db query uses OR condition so there would be no effect on sql result) --- Editor.php | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/Editor.php b/Editor.php index 4bacb11..adc9b4a 100644 --- a/Editor.php +++ b/Editor.php @@ -1911,40 +1911,6 @@ private function _ssp_filter($query, $http) // For every selection in every column foreach ($this->_fields as $field) { if (isset($http['searchPanes'][$field->name()])) { - for ($i = 0; $i < count($http['searchPanes'][$field->name()]); ++$i) { - // Check the number of rows... - $q = $db - ->query('select') - ->table($this->_table) - ->get('COUNT(*) as cnt'); - - $q->left_join($this->_leftJoin); - - // ... where the selected option is present... - if ( - isset($http['searchPanes_null'][$field->name()][$i]) - && $http['searchPanes_null'][$field->name()][$i] === 'true' - ) { - $q->where($field->dbField(), null, '='); - } else { - $q->where( - $field->dbField(), - $http['searchPanes'][$field->name()][$i], - '=' - ); - } - - $r = $q - ->exec() - ->fetchAll(); - - // ... If there are none then don't bother with this selection - if ($r[0]['cnt'] == 0) { - array_splice($http['searchPanes'][$field->name()], $i, 1); - --$i; - } - } - $query->where(static function ($q) use ($field, $http) { for ($j = 0; $j < count($http['searchPanes'][$field->name()]); ++$j) { if (