Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Need some performance help

Author  Topic 

davidmal
Starting Member

19 Posts

Posted - 2008-08-21 : 12:51:25
Greetings all,

Please help a DBA challenged developer.

I have an IP geolocation database with this schema:
rngID int PK, Unique, Clustered
startIpNum bigint IDX, Unique, Non-Clustered, Fillfactor=95%
endIpNum bigint IDX, Unique, Non-Clustered, Fillfactor=95%
country nchar(50)
region nchar(50)
city nchar(50)
postalCode nchar(20)
areaCode nchar(18)

This table has 2,942,551 records

When I execute a query to extract the location

select * from IPCityState
WHERE startIpNum <= 1147705496 *
AND endIpNum >= 1147705496 *
*note - this value would normally passed as a parameter

The query takes 18-24 seconds. I can programmatically scrape a geolocation website faster than that (It's just not entirely legal so I'd rather not).
This is the only query that will be being called on this table. That is why I only indexed the startIpNum and endIpNum columns.

Any suggestions as to how to pull the data faster?

Dave





tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-21 : 13:02:52
Are you really using * in your query? Have you tried a covering index: startIpNum,endIpNum with include columns of whatever your query returns (please return only what you need and not *).

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-21 : 13:03:26
How does fragmentation look on this table? Have you updated statistics?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-08-21 : 13:20:03
What is the nature of the data in the two columns startIPNum and endIPNum? ie: Does any given parameter value only have 1 row that would satisfy the query or are there many rows returned? If many, how many?

If the data is designed to "trap" a row or range of rows surrounding one input value then a clustered index on your (startIPNum, endIPNum) may be perfect for that query (rather than a clustered index on mgID).

But no matter what 20 seconds seems too long for 3m rows so Tara may be on to something or perhaps concurrent requests are blocking.

Be One with the Optimizer
TG
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-08-21 : 13:20:29
What does execution plan say about it? Clustered index scan --Bookmarklookup.
Go to Top of Page
   

- Advertisement -