in reply to Slow response on DBI MySQL query
There are many things you can cache to make executing your subroutine faster.
For example, you can cache the statement handle $obtain_country to fetch a single country:
use vars '$obtain_country'; sub Obtain_GeoIP { ... $obtain_country ||= $obtain_country = $dba->prepare("select Countr +y from GeoIP where $lip between Start_int and End_int limit 1"); };
You could also restructure the query and instead of issuing a query for each IP address, insert all IP addresses into a table and then query the countries for them through SQL.
I'm not sure if a table is the best data structure for a range query and personally, I would just use the Geo::IP module.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Slow response on DBI MySQL query
by Fortificus (Novice) on Mar 24, 2015 at 14:10 UTC | |
by Corion (Patriarch) on Mar 24, 2015 at 14:11 UTC | |
by Fortificus (Novice) on Mar 24, 2015 at 14:19 UTC | |
by Fortificus (Novice) on Mar 24, 2015 at 14:13 UTC | |
by Corion (Patriarch) on Mar 24, 2015 at 14:14 UTC | |
by fishmonger (Chaplain) on Mar 24, 2015 at 14:21 UTC | |
by Fortificus (Novice) on Mar 24, 2015 at 14:25 UTC | |
by chacham (Prior) on Mar 24, 2015 at 14:41 UTC |