? example.patch
Index: views_fastsearch.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_fastsearch/views_fastsearch.module,v
retrieving revision 1.2.2.40
diff -u -p -r1.2.2.40 views_fastsearch.module
--- views_fastsearch.module	11 Aug 2007 04:25:03 -0000	1.2.2.40
+++ views_fastsearch.module	10 Aug 2010 15:20:42 -0000
@@ -159,16 +159,20 @@ function views_fastsearch_views_handler_
                 }
                 // FALLTHROUGH
               default:
-                if (!$search_index_unique) {
-                  $tnc = $query->add_table('search_index', TRUE);
-                  $tablename = $query->get_table_name('search_index', $tnc);
-                  $extra['AND'][] = "$tablename.word='%s'";
-                  if ($filter['options']) {
+                // enforce throttle
+                $throttle = variable_get('word_number_throttle', NULL);
+                if ($throttle && $word_count < $throttle) {
+                  if (!$search_index_unique) {
+                    $tnc = $query->add_table('search_index', TRUE);
                     $tablename = $query->get_table_name('search_index', $tnc);
-                    $query->add_where("$tablename.type='%s'", $filter['options']);
+                    $extra['AND'][] = "$tablename.word='%s'";
+                    if ($filter['options']) {
+                      $tablename = $query->get_table_name('search_index', $tnc);
+                      $query->add_where("$tablename.type='%s'", $filter['options']);
+                    }
                   }
+                  $values['AND'][] = $value;
                 }
-                $values['AND'][] = $value;
                 break;
             }
           }
@@ -589,6 +593,14 @@ function views_fastsearch_form_alter($fo
           '#default_value' => variable_get('search_index_unique', 0),
           '#description' => t('The {search_index} may have duplicate entries caused by overlapping cron runs.  This happens less frequently since Drupal 5.x, but still can occur.  The best solution is to create a UNIQUE index using "ALTER IGNORE TABLE search_index ADD UNIQUE INDEX (sid, word, type, fromsid)".  If you have created this index or if you know your site does not have duplicates, select UNIQUE so that the faster views_fastsearch algorithm may be used.  See <a href="@url">%nid</a>', array('@url' => 'http://drupal.org/node/143160', '%nid' => '#143160')),
         ),
+        'word_number_throttle' => array(
+          '#type' => 'textfield',
+          '#title' => t('Throttle queries at this many words'),
+          '#size' => 3,
+          '#maxlength' => 3,
+          '#default_value' => variable_get('word_number_throttle', NULL),
+          '#description' => t('Depending on the situation, AND queries can sometimes use up a lot of system resources. By throttling searches at 10 words, for example, you ensure that the majority of searches will run unchanged (longer queries would only accept the first 10 words) without slowing down your database.'),
+        ),
       ),
     );
 
