Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
search.module uses
$count = db_num_rows(db_query("SELECT DISTINCT i.sid, i.type FROM {search_index} i $join WHERE $conditions", $arguments));
I think using COUNT(i.sid) should provide an increase in effiecency.
Waiting for comments.
BTW there are 5 more occurances of "db_num_rows(db_query(" is there any reason for that?
Comment | File | Size | Author |
---|---|---|---|
search.module.patch.txt | 848 bytes | Thomas Ilsche |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedthose 2 queries are not equivalent. look at the DISTINCT operator. Furthermore, the COUNT(*) optimization does not apply to multiple table queries (I think).
db_num_rows() is indeed useful.
Comment #2
Thomas Ilsche CreditAttribution: Thomas Ilsche commentedSorry, dunno why I didnt see that.
Even with no optimization it would be slightly more efficient since it reduces mysql<->php traffic. Anyway I currently see no way to get an equivalent COUNT query.