Content search is a problem

Hi;
the system is rt-3.6.1, mysql Distrib 5.1.12-beta, apach2 and mod_perl
2,dbix 1.45
the hardware web server intel 3.2 G processor 4G memory and 1 db server
athlon 2 dual core 2.2 G proc and 16 G memory
The system is optimised, and all functionality is fairly quick and
smooth with the exception of content searches, a query like :
SELECT COUNT(DISTINCT main.id) FROM Tickets main , Transactions
Transactions_1, Attachments Attachments_2 WHERE
((Transactions_1.ObjectType = ‘RT::Ticket’)) AND ((main.EffectiveId =
main.id)) AND ((main.Status != ‘deleted’)) AND ((main.Type = ‘ticket’))
AND ((main.Created > ‘2006-07-14 23:00:00’) AND (main.Queue != ‘132’)
AND (main.Status != ‘rejected’) AND (main.id > ‘178000’) AND (
(main.Subject LIKE ‘%my text%’) OR ( (Attachments_2.Content LIKE
‘%mytext%’) AND (Attachments_2.TransactionId = Transactions_1.id) AND
(main.id = Transactions_1.ObjectId) ) ) ) just hangs and not return
anything and in the process effect the performance for other users an
explain of the query :
| id | select_type | table | type |
possible_keys | key |
key_len | ref | rows | Extra |
| 1 | SIMPLE | main | range |
PRIMARY,Tickets1,Tickets3,Tickets4,Tickets5,Tickets6 | PRIMARY |
4 | NULL | 83328 | Using where |
| 1 | SIMPLE | Transactions_1 | ref |
PRIMARY,Transactions1,Transactions2 | Transactions1 |
66 | const | 1894666 | Using where; Using index |
| 1 | SIMPLE | Attachments_2 | ALL |
Attachments2 | NULL |
NULL | NULL | 7134357 | Using where |

I am not sure what can be done to improve this, we have 230000 tickets
and the attachments table have 1774299 rows and 5G in size, we
partitioned the atatchments table into 100000 row segments , which
improved everything else but I feel slows the content searching, has
anyone got any ideas?? any help will truly be appreciated.
Regards;
Roy

Here’s a patch I use to prevent content searches from searching named
attachments (uploaded files). This patch is to 3.6.1, but I haven’t
tested it much.

I create a modified version of $RTHOME/lib/RT/Tickets_Overlay.pm in
$RTHOME/local/lib/RT/.

This patch is contingent on a configuration variable, so the following
has to be added to RT_SiteConfig.pm:

If $DontSearchFileAttachments is set to a true value, then

named

attached files are not searched. Although this is usually

what

users expect, it is not the

default.

Set($DontSearchFileAttachments, ‘true’);

Here’s the patch:

— old/Tickets_Overlay.pm 2006-07-18 17:51:35.000000000 -0400
+++ new/Tickets_Overlay.pm 2006-10-23 20:14:39.000000000 -0400
@@ -679,14 +679,36 @@
$self->_OpenParen;

 #Search for the right field
  • $self->_SQLLimit(
  •    ALIAS         => $self->{_sql_trattachalias},
    
  •    FIELD         => $field,
    
  •    OPERATOR      => $op,
    
  •    VALUE         => $value,
    
  •    CASESENSITIVE => 0,
    
  •    @rest
    
  • );
  • if ($field eq ‘Content’ and $RT::DontSearchFileAttachments) {

  •   $self->_SQLLimit(
    
  •                   ALIAS         => $self->{_sql_trattachalias},
    
  •                   FIELD         => 'Filename',
    
  •                   OPERATOR      => 'IS',
    
  •                   VALUE         => 'NULL',
    
  •                   SUBCLAUSE     => 'contentquery',
    
  •                   ENTRYAGGREGATOR => 'AND',
    
  •                  );
    
  •   $self->_SQLLimit(
    
  •                   ALIAS         => $self->{_sql_trattachalias},
    
  •                   FIELD         => $field,
    
  •                   OPERATOR      => $op,
    
  •                   VALUE         => $value,
    
  •                   CASESENSITIVE => 0,
    
  •                   @rest,
    
  •                   ENTRYAGGREGATOR => 'AND',
    
  •                   SUBCLAUSE     => 'contentquery',
    
  •                  );
    
  • } else {

  •   $self->_SQLLimit(
    
  •                   ALIAS         => $self->{_sql_trattachalias},
    
  •                   FIELD         => $field,
    
  •                   OPERATOR      => $op,
    
  •                   VALUE         => $value,
    
  •                   CASESENSITIVE => 0,
    
  •                   ENTRYAGGREGATOR => 'AND',
    
  •                   @rest
    
  •                  );
    
  • }

    $self->_SQLJoin(
    ALIAS1 => $self->{_sql_trattachalias},