<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: MaxMind GeoIP: Import MaxMind City CSVs into SQL Server 2005</title>
	<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/</link>
	<description>ls /usr/lolcat</description>
	<pubDate>Wed, 20 Aug 2008 02:12:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Charles</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-10301</link>
		<dc:creator>Charles</dc:creator>
		<pubDate>Thu, 31 Jul 2008 15:16:39 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-10301</guid>
		<description>As solution to the problem I wrote about above, you're look logic can be done like this:

SELECT TOP 1
	case when @intIPNum &#62; [Last] then null else locid end
FROM GeoIPCityBlocks WHERE @intIPNum &#62;= startIpNum ORDER BY startIpNum DESC

This query will return NULL in the case @intIPNum is not found between any ranges within the database.

Charles</description>
		<content:encoded><![CDATA[<p>As solution to the problem I wrote about above, you're look logic can be done like this:</p>
<p>SELECT TOP 1<br />
	case when @intIPNum &gt; [Last] then null else locid end<br />
FROM GeoIPCityBlocks WHERE @intIPNum &gt;= startIpNum ORDER BY startIpNum DESC</p>
<p>This query will return NULL in the case @intIPNum is not found between any ranges within the database.</p>
<p>Charles</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-10298</link>
		<dc:creator>Charles</dc:creator>
		<pubDate>Mon, 28 Jul 2008 16:31:56 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-10298</guid>
		<description>Your lookup logic incorrectly assumes that endIpNum at row X is always one less than startIpNum at row X+1. That is, your code is assuming contiguous IP ranges like this:

startIpNum                endIpNum                  locId
67276848 (4.2.144.48)     67277023 (4.2.144.223)    223
67277024 (4.2.144.224)    67277031 (4.2.144.231)    994
67277032 (4.2.144.232)    67277039 (4.2.144.239)    223
67277040 (4.2.144.240)    67277047 (4.2.144.247)    33539
67277048 (4.2.144.248)    67277055 (4.2.144.255)    4027
67277056 (4.2.145.0)      67277215 (4.2.145.159)    15886

But this is not true for all rows. Here is some data directly from the database ordered by startIpNum:

startIpNum                    endIpNum                      locId
368674304 (21.249.134.0)      385875967 (22.255.255.255)    223
386665696 (23.12.12.224)      386665727 (23.12.12.255)      58390
386666240 (23.12.15.0)        386666367 (23.12.15.127)      58393
393849728 (23.121.171.128)    393849735 (23.121.171.135)    32371
402653184 (24.0.0.0)          402653695 (24.0.1.255)        118769
402653696 (24.0.2.0)          402653951 (24.0.2.255)        57771

Your logic returns a locId of 58393 for all the IP address between 23.12.15.128 and 23.121.171.127, but in actuality those addresses have no entry in the database. That's 7,183,361 IP addresses that get resolved to Great Britain when in fact the database doesn't say that.

Please correct me if I'm wrong.

Charles</description>
		<content:encoded><![CDATA[<p>Your lookup logic incorrectly assumes that endIpNum at row X is always one less than startIpNum at row X+1. That is, your code is assuming contiguous IP ranges like this:</p>
<p>startIpNum                endIpNum                  locId<br />
67276848 (4.2.144.48)     67277023 (4.2.144.223)    223<br />
67277024 (4.2.144.224)    67277031 (4.2.144.231)    994<br />
67277032 (4.2.144.232)    67277039 (4.2.144.239)    223<br />
67277040 (4.2.144.240)    67277047 (4.2.144.247)    33539<br />
67277048 (4.2.144.248)    67277055 (4.2.144.255)    4027<br />
67277056 (4.2.145.0)      67277215 (4.2.145.159)    15886</p>
<p>But this is not true for all rows. Here is some data directly from the database ordered by startIpNum:</p>
<p>startIpNum                    endIpNum                      locId<br />
368674304 (21.249.134.0)      385875967 (22.255.255.255)    223<br />
386665696 (23.12.12.224)      386665727 (23.12.12.255)      58390<br />
386666240 (23.12.15.0)        386666367 (23.12.15.127)      58393<br />
393849728 (23.121.171.128)    393849735 (23.121.171.135)    32371<br />
402653184 (24.0.0.0)          402653695 (24.0.1.255)        118769<br />
402653696 (24.0.2.0)          402653951 (24.0.2.255)        57771</p>
<p>Your logic returns a locId of 58393 for all the IP address between 23.12.15.128 and 23.121.171.127, but in actuality those addresses have no entry in the database. That's 7,183,361 IP addresses that get resolved to Great Britain when in fact the database doesn't say that.</p>
<p>Please correct me if I'm wrong.</p>
<p>Charles</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-1214</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Wed, 09 Jan 2008 13:48:33 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-1214</guid>
		<description>You can use another technique proposed by IP2Location. It is using format file to define CSV format for command line import.

http://www.ip2location.com/faqs-ip-country.aspx#9</description>
		<content:encoded><![CDATA[<p>You can use another technique proposed by IP2Location. It is using format file to define CSV format for command line import.</p>
<p><a href="http://www.ip2location.com/faqs-ip-country.aspx#9" rel="nofollow">http://www.ip2location.com/faqs-ip-country.aspx#9</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Emil Zegers</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-881</link>
		<dc:creator>Emil Zegers</dc:creator>
		<pubDate>Wed, 07 Nov 2007 10:38:33 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-881</guid>
		<description>I've used your scripts to import the MaxMind data in MSDE (Microsoft SQL Server Desktop Engine 8.00.760).

To get this done, the following adjustments to the scripts had to be made:

SQL script:

- Changed 'sys.databases' and 'sys.objects' to 'sysdatabases' and 'sysobjects'

- Changed 'WHERE object_id = OBJECT_ID' to 'WHERE id = OBJECT_ID'

- Added index name to INDEXDEFRAG:

DBCC INDEXDEFRAG (maxmindgeoip,GeoIPCountry,IDX_countryStarIPtNum)
DBCC INDEXDEFRAG (maxmindgeoip,GeoIPCountry,IDX_CountryCode)
DBCC INDEXDEFRAG (maxmindgeoip,GeoIPCityBlocks,IDX_blocksStartIpNum)
DBCC INDEXDEFRAG (maxmindgeoip,geoIPCityLocation,IDX_LocationID)

- Changed 'GRANT CONNECT TO [guest]' to 'EXECUTE sp_grantdbaccess [guest]'

- Added percentage and truncate parameter to SHRINKDATABASE

DBCC SHRINKDATABASE (maxmindGeoIP,10,NOTRUNCATE)

Thanks for your scripts!

Regards,

Emil</description>
		<content:encoded><![CDATA[<p>I've used your scripts to import the MaxMind data in MSDE (Microsoft SQL Server Desktop Engine 8.00.760).</p>
<p>To get this done, the following adjustments to the scripts had to be made:</p>
<p>SQL script:</p>
<p>- Changed 'sys.databases' and 'sys.objects' to 'sysdatabases' and 'sysobjects'</p>
<p>- Changed 'WHERE object_id = OBJECT_ID' to 'WHERE id = OBJECT_ID'</p>
<p>- Added index name to INDEXDEFRAG:</p>
<p>DBCC INDEXDEFRAG (maxmindgeoip,GeoIPCountry,IDX_countryStarIPtNum)<br />
DBCC INDEXDEFRAG (maxmindgeoip,GeoIPCountry,IDX_CountryCode)<br />
DBCC INDEXDEFRAG (maxmindgeoip,GeoIPCityBlocks,IDX_blocksStartIpNum)<br />
DBCC INDEXDEFRAG (maxmindgeoip,geoIPCityLocation,IDX_LocationID)</p>
<p>- Changed 'GRANT CONNECT TO [guest]' to 'EXECUTE sp_grantdbaccess [guest]'</p>
<p>- Added percentage and truncate parameter to SHRINKDATABASE</p>
<p>DBCC SHRINKDATABASE (maxmindGeoIP,10,NOTRUNCATE)</p>
<p>Thanks for your scripts!</p>
<p>Regards,</p>
<p>Emil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Hooker</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-624</link>
		<dc:creator>James Hooker</dc:creator>
		<pubDate>Wed, 25 Apr 2007 01:47:00 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-624</guid>
		<description>Fantastic, thank you very much! This little package does exactly what it says on the tin! :)</description>
		<content:encoded><![CDATA[<p>Fantastic, thank you very much! This little package does exactly what it says on the tin! <img src='http://blog.netnerds.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drew Freyling</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-623</link>
		<dc:creator>Drew Freyling</dc:creator>
		<pubDate>Fri, 02 Mar 2007 07:07:44 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-623</guid>
		<description>I'm guessing the overhead of setting that everytime the proc is run is greater than the performance gain from not row/table locking on each read.</description>
		<content:encoded><![CDATA[<p>I'm guessing the overhead of setting that everytime the proc is run is greater than the performance gain from not row/table locking on each read.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chrissy</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-622</link>
		<dc:creator>Chrissy</dc:creator>
		<pubDate>Thu, 01 Mar 2007 22:58:42 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-622</guid>
		<description>Hey Drew,
That seemed very possible so I tried it out by adding the following to the store procedure:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

Strangely, it actually slowed down the query. The average resolution for 255 IPs without the explicit transaction level was 189ms on average and with the transaction level set, it was 204 ms.</description>
		<content:encoded><![CDATA[<p>Hey Drew,<br />
That seemed very possible so I tried it out by adding the following to the store procedure:</p>
<p>SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED</p>
<p>Strangely, it actually slowed down the query. The average resolution for 255 IPs without the explicit transaction level was 189ms on average and with the transaction level set, it was 204 ms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drew Freyling</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-621</link>
		<dc:creator>Drew Freyling</dc:creator>
		<pubDate>Wed, 28 Feb 2007 02:29:46 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-621</guid>
		<description>Will setting the transaction isolation level to read uncommitted( thereby removing the locking overhead) make the IPtoLocation proc perform any quicker?</description>
		<content:encoded><![CDATA[<p>Will setting the transaction isolation level to read uncommitted( thereby removing the locking overhead) make the IPtoLocation proc perform any quicker?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jrp</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-620</link>
		<dc:creator>jrp</dc:creator>
		<pubDate>Sat, 24 Feb 2007 13:33:49 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-620</guid>
		<description>The answer to the permissions problem seems to be to right click on unzip.exe and click Unblock</description>
		<content:encoded><![CDATA[<p>The answer to the permissions problem seems to be to right click on unzip.exe and click Unblock</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jrp</title>
		<link>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-619</link>
		<dc:creator>jrp</dc:creator>
		<pubDate>Fri, 23 Feb 2007 23:04:40 +0000</pubDate>
		<guid>http://blog.netnerds.net/2007/01/maxmind-geoip-import-maxmind-city-csv-into-sql-server-2005/#comment-619</guid>
		<description>I still get "permission denied" problems running the vbs script.  Suggestions for debugging?</description>
		<content:encoded><![CDATA[<p>I still get "permission denied" problems running the vbs script.  Suggestions for debugging?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
