Closed (fixed)
Project:
Visitors (Web Analytics)
Version:
6.x-1.0-alpha4
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Sep 2011 at 14:36 UTC
Updated:
15 Jan 2012 at 14:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
roball commentedMay I ask when you intend to work on this?
Comment #2
gashev commentedIn the coming days I'll doing script.
Comment #3
gashev commentedCheck please. Mysql, pgsql support. Rename update.txt to update.php. Update db connection params (see lines 5-10) and exec php script from command string. Script can run many time for update all data.
Comment #5
roball commentedThanks for the script.
It works, but unfortunately very slow. One IP takes approx. 2 seconds to update! In one of my sites I have approx. 500000 rows in the {visitors} table - thus updating them all would take about 12 entire days!
And I have lots of similar sites in the same (multisite) Drupal installation.
Any faster approach?
And, instead of outputting each and every updated IP address I would suggest to print outputs like "n IP addresses updated in x seconds" every x seconds (where x is a defined interval of maybe 60).
Comment #6
gashev commentedYou have 500000 rows. Script does not update per row. This script updates all the entries for each ip. What count of uniq ip do you have? Exec mysql query: select count(distinct visitors_ip) from {visitors}. If you have 5000 different ip, and one ip takes approx. 2 seconds to update, you need 3 hours to update all records (5000 ips it's 10000 seconds; 10000 seconds it's 2.78 hours).
Comment #7
roball commentedYeah, you are right, not all 500000 rows need to be updated.
gives approx. 22500, thus it would still take 22500*2/3600 = 12,5 hours :-(
Comment #8
gashev commentedYou can create index to visitors_ip row:
CREATE INDEX ip ON visitors (visitors_ip) USING BTREE;
And exec update script.
On my pc (5000 uniq ips):
$ time php update.php
real 0m19.923s
user 0m0.420s
sys 0m0.312s
Comment #9
roball commentedBefore digging into performance optimisation, I have enhanced your script to enable incremental updates, along with other enhancements such as printing a more useful output. So far, if the script did not complete in one run, it would re-calculate *all* IP addresses on the next run, thus making it impossible to complete in more than one run.
This version only updates those (unique) IP addresses that have not yet been resolved into GeoIP data, and prints how many IPs have to be processed at the beginning and how many were completed at the end. Also, it integrates into the module and can be executed on the command-line from the "cli" sub directory. Running via the webbrowser is prohibited.
Here is an example output from two subsequent test runs with the setting
:
Here is the result of a run with
$max_runtime = 3600 * 3;(3 hours):Comment #10
gashev commentedThank you for script updates.
Comment #11
roball commentedHm, may I ask why you have changed the status of this issue to fixed? I don't see a code commit.
Comment #12
gashev commentedThis script is used only for migration to new version and will not to be used to next versions. I do not see any sense to commit this code.
Comment #13
roball commentedOK, no problem for me. Attached is a slightly improved version of the script.
And, adding an index on the visitors_ip column indeed increased performance drastically!
Why not adding the index by the module itself?
Comment #14
roball commentedThe attached version of the update script fixes a small bug.
Comment #15
gashev commented> Why not adding the index by the module itself?
I want to fix it, but I need to check:
1) For which columns I need to add an index.
2) How it works on large amounts of data when adding new entries on using mysql/innodb engines.
Comment #17
gashev commentedComment #18
gashev commentedComment #19
gashev commented