From 70a32a158db8c630e11263b36a9c14e04d3f3f0b Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Tue, 28 Oct 2014 17:42:22 +0100
Subject: [PATCH] full text: optimise empty string search.

---
 product/ZSQLCatalog/Operator/ComparisonOperator.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/product/ZSQLCatalog/Operator/ComparisonOperator.py b/product/ZSQLCatalog/Operator/ComparisonOperator.py
index b79d079eb3..384ba10a7a 100644
--- a/product/ZSQLCatalog/Operator/ComparisonOperator.py
+++ b/product/ZSQLCatalog/Operator/ComparisonOperator.py
@@ -107,6 +107,10 @@ class MatchComparisonOperator(MonovaluedComparisonOperator):
       This operator can emit a select expression, so it overrides
       asSQLExpression inseatd of just defining a render method.
     """
+    # No need fo do full text search for an empty string.
+    if value_list == '':
+      column, value_list = self.render(column, value_list)
+      return SQLExpression(self, where_expression='%s %s %s' % (column, '=', value_list))
     value_list = self.renderValue(value_list)
     match_string = self.where_expression_format_string % {
       'column': column,
-- 
2.30.9