Opened 11 years ago

Closed 11 years ago

#528 closed cleanup (fixed)

non indexed query in amavisd-maia

Reported by: mortonda@… Owned by: mortonda@…
Priority: normal Milestone: 1.0.3
Component: amavisd-maia Version: 1.0.2
Severity: minor Keywords:
Cc:

Description

Arnaud reports:

I was playing with the log-queries-not-using-indexes of mysql,
and saw some select from maia in it:

use maia;
SELECT id, rule_count, rule_score_3 FROM maia_sa_rules WHERE rule_name LIKE 'SARE_GIF_ATTACH';

It comes from amavisd-maia, line 4288:

       # look up the test by name in the maia_sa_rules table
       $select = "SELECT id, rule_count, rule_score_3 FROM maia_sa_rules WHERE rule_name = ?";

In HEAD, line 4285:

       $select = "SELECT id, rule_count, rule_score_3 FROM maia_sa_rules WHERE rule_name LIKE ? LIMIT 1";


Why is there a "LIKE" ? Seems to me it would work very well with
a '=' , as there is no '%' or any other thing... And thus would
use indexes.

Change History (4)

comment:1 Changed 11 years ago by mortonda@…

  • Resolution set to fixed
  • Status changed from new to closed

[1410] and [1411]

I'm not sure if it was needed, I thought LIKE can use indexes in some cases. Nevertheless, ' is more readable anyway.

comment:2 Changed 11 years ago by mortonda@…

crrection, that's [1410] and [1412]

comment:3 Changed 11 years ago by rjl@…

  • Resolution fixed deleted
  • Status changed from closed to reopened

As Blake Hudson pointed out, there are two more LIKEs that should be replaced in maia_record_viruses() as well. The LIKE in maia_get_mysql_size_limit() needs to remain as it is, but should not present any performance issues.

comment:4 Changed 11 years ago by mortonda@…

  • Resolution set to fixed
  • Status changed from reopened to closed

already did... see patches... ;)

Note: See TracTickets for help on using tickets.