Big problems on optimizing query
Hi,
my tables are created with following statements:
CREATE TABLE t1 (
tid int(11) NOT NULL AUTO_INCREMENT,
someData varchar(45),
PRIMARY KEY (`tid`),
KEY `fk_did` (`someData`)
) ENGINE=MyISAM;
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
tid int(11) NOT NULL,
someData varchar(45),
PRIMARY KEY (`id`),
KEY `idx_tid` (`tid`)
) ENGINE=MyISAM;
In my real application t1 contains about 1,500 datasets and t2 about 85,000,000 datasets. I have big problems to executing following query:
(q1) SELECT t2.* FROM t1 inner join t2 on t1.tid = t2.tid where t1.someData = 'iPhone';
The result requires minutes. Let's assume the id for "iPhone" is "123". Following query requires only 2ms:
(q2) SELECT * FROM t2 where t2.tid = 123;
Running an "explain" on query (q2) shows me, that the index "idx_tid" is used for processing the query, but not for query (q1). A query hint like "force index" does not change anything.
Is there a chance to use the index "idx_tid" for query (q1) and run the query nearly as fast as (q2)?
Subject
Views
Written By
Posted
Big problems on optimizing query
4016
September 20, 2010 06:28AM
1601
September 23, 2010 09:29AM
1645
September 24, 2010 04:32AM
1550
September 24, 2010 10:24PM
1606
September 27, 2010 08:56AM
1452
September 28, 2010 05:18PM
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.