From 5226a0149d1d49aef506535c8d27b00981dcd115 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 29 Apr 2020 16:37:27 +0200 Subject: Check fields used with NI for NULL first to take advantage of indices --- it_dbi.class | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/it_dbi.class b/it_dbi.class index 3620018..39f50a7 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -401,7 +401,7 @@ function _where($params) foreach ((array)$value as $val) $parts[] = "CONCAT(',',$field,',') LIKE " . $this->escape_string("%,$val,%"); - $query .= $sep . "(" . join(" OR ", $parts) . ")"; + $query .= $sep . "$field IS NOT NULL AND (" . join(" OR ", $parts) . ")"; # Check for IS NOT NULL to take advantage of index } else $query .= $sep . "1"; -- cgit v1.2.3