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?

CommentFileSizeAuthor
search.module.patch.txt848 bytesThomas Ilsche
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

those 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.

Thomas Ilsche’s picture

Status: Needs review » Closed (fixed)

Sorry, 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.