Advertisement

04.18.2005 at 05:53PM PDT, ID: 21393600
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

How do I get mysql to utilize the table's key??

Asked by hncwalker in MySQL Server

I'm hoping someone can help me figure out what is wrong here.
Here is the deal. I have a new IP-country database list that I
put into a myisiam table. The problem is queries to locate a country
using this table is taking MUCH longer than our current IP-country table,
and I cannot figure out why. Using explain shows that MYSQL isn't using
any keys when executing the query.

Here is the database structure:

CREATE TABLE `ipcountryNEW` (
`ipFROM` int(10) unsigned zerofill NOT NULL default '0000000000',
`ipTO` int(10) unsigned zerofill NOT NULL default '0000000000',
`countrySHORT` char(2) NOT NULL default '',
`countryLONG` varchar(255) NOT NULL default '',
`Region` varchar(128) NOT NULL default '',
`City` varchar(128) NOT NULL default '',
PRIMARY KEY (`ipFROM`,`ipTO`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
*************************************************************
Here is an example query:
mysql> select countryLONG from ipcountryNEW where 1142156934 between ipFROM AND ipTO;
+---------------+
| countryLONG |
+---------------+
| UNITED STATES |
+---------------+
1 row in set (4.04 sec) <<< 4 seconds?!  Way too long!!
*************************************************************
mysql> select count(*) from ipcountryNEW;
+----------+
| count(*) |
+----------+
| 1554025 |
+----------+
1 row in set (0.09 sec)
*************************************************************
--Even if I try a little different query, I still don't get the engine to use the key...

mysql> EXPLAIN select countryLONG from ipcountryNEW where ipFROM>=1142156934 AND ipTO<=1142156934;
+----+-------------+--------------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | ipcountryNEW | ALL | PRIMARY | NULL | NULL | NULL | 1554025 | Using where |
+----+-------------+--------------+------+---------------+------+---------+------+---------+-------------+
1 row in set (0.09 sec)
*************************************************************
mysql> explain select countryLONG from ipcountryNEW where 1142156934 between ipFROM AND ipTO;
+----+-------------+--------------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | ipcountryNEW | ALL | NULL | NULL | NULL | NULL | 1554025 | Using where |
+----+-------------+--------------+------+---------------+------+---------+------+---------+-------------+
1 row in set (0.24 sec)
*************************************************************Start Free Trial
[+][-]04.18.2005 at 06:22PM PDT, ID: 13811836

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MySQL Server
Sign Up Now!
Solution Provided By: kupra1
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.19.2005 at 07:26AM PDT, ID: 13815746

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.03.2006 at 05:45AM PST, ID: 15863052

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02.07.2006 at 04:03AM PST, ID: 15891414

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32