Closed (fixed)
Project:
Drupal core
Version:
4.6.0
Component:
search.module
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
10 Aug 2005 at 18:16 UTC
Updated:
10 Aug 2005 at 18:45 UTC
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 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 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.