Closed (fixed)
Project:
Counter
Version:
6.x-2.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Nov 2009 at 21:53 UTC
Updated:
14 May 2010 at 15:49 UTC
Jump to comment: Most recent file
I have a counter table with over 1mln records so probably this is why I am experiencing all the problems. However, I still think that most of the problems could be avoided in one or another way.
Just looking into the code:
Last lines look like:
if ($counter_show_administer_only && !user_access('administer counter')) {
return;
} else {
return $block;
}
Please note, if the 'if' statement is true the block returns an empty result but even then it still does all the calculations and executes all database queries. This is clearly a mistake.
I suggest to put this 'if' statement at the beginning of the function to avoid all the costly code executions if the function returns an empty result anyway.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | couter_skip_admin.png | 17.01 KB | drupalnesia |
Comments
Comment #1
kobit commentedThe same actually applies to showing 'Since:' date. The module first loads the data from database and then checks whether to use to user provided date or the date loaded from the database. In case the user provided the date to use the database request is a waste and impacts performance even though the query results are not actually used at all.
Comment #2
drupalnesia commentedThe $counter_show_administer_only is not used for disable counting process. This variable used for HIDE the Counter block, that's why all query still execute.
The variable to SKIP all query for Admin is: $counter_skip_admin.
Look at attached image in this post.
Comment #3
drupalnesia commented6.x-2.3: Bug fix: Performance, add index to counter: counter_date and counter_ip
In my test Counter module performance increase 300%, and only requires < 1 s to execute the slow queries before, as shown below:
-----------------------------------------------------------
0.6 1 SELECT counter_date FROM counter ORDER BY counter_date DESC LIMIT 1
0.77 SELECT count(*) as total FROM (SELECT counter_ip FROM counter GROUP BY counter_ip) c
-----------------------------------------------------------
Please test and report again, thanks.
Comment #4
drupalnesia commentedFixed.