MySQL Forums
Forum List  »  Performance

Re: Slow JOIN to convert IP to Country Code
Posted by: Harutyun Drnoyan
Date: May 21, 2009 01:34AM

Hello.

Thanks for replies.

Saying the same query I mean

SELECT stat.ipFROM stats AS stat
WHERE dateline>=1242604800 AND dateline<1242691200;

And, yes it takes only ~0.0013 seconds to run.

About 20K rows in EXPLAIN. I've wondered of these too. The above simple select query returns ~710 rows, but EXPLAIN says it scanned ~19000 rows. It seems that with large tables these numbers do not need to be the same. Or may be it's because table data is too fragmented on hard drive?

I decided to solve this issue normalizing my data once more (something like Aftab Khan suggested).
Primary key will be added to iplist table and reference to it will be stored with each row in stats table. This adds on more query at insert time (to get interval id for current ip) and some more data to stats table (one unsigned int column), nut will allow to get ip interval data using ref type of join and not a full table scan (~91000 rows). I decided to add integer primary key and not country code to keep stats table as small as possible.

I'll update here about results of this modification,

Thanks for help.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.