Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Slow response on DBI MySQL query

by Fortificus (Novice)
on Mar 25, 2015 at 19:35 UTC ( [id://1121330]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Slow response on DBI MySQL query
in thread Slow response on DBI MySQL query

Monks, after doing all recommended changes I was able to process 3,000 records per second (for a total of 259,200,000 records a day). All changes had some positive effect, but the one that had the most dramatic effect was moving to Geo::IP. As it was mentioned on the thread by a few of you guys, the relational database was certainly not the correct place to do this operation. The finalized code looks like this now:
sub Obtain_GeoIP { $GeoIP_resolved++; my ($IP) = @_; if($IP=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ &&(($1< +=255 && $2<=255 && $3<=255 &&$4<=255 ))) { my @sip = split(/\./,$IP); if (($sip[0] == "10") || ($sip[0] == "192" && $sip[1] == "168" +) || (($sip[0] == "172" && $sip[1] >= "16") && ($sip[0] == "172" && $ +sip[1] <= "31"))) { return "Internal Network"; } else { if ( exists $geoip_hash{IP} ) { my $country_hash = $ge +oip_hash{IP}; return $country_hash; } my $country = $gi->country_name_by_addr($IP); $geoip_hash{$IP} = $country; return $country; } } else { print EFILE "IP address sent to Obtain_GeoIP routine w +as incorrect: $IP - $counter\n"; } }
Thank you very much for everybody's help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1121330]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-25 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found