I have the following scenario: in a MySQL database, I have 2 MyISAM tables, one of which contains 4.2 million rows and the other contains 320 million rows. Below is the table layout:
Table 1 (rows 4.2M)
F1 INTEGER UNSIGNED NOT NULL PRIMARY KEY
f2 varchar(40)
f3 varchar(40)
f4 varchar(40)
f5 varchar(40)
f6 smallint(6)
f7 smallint(6)
f8 varchar(40)
f9 varchar(40)
f10 smallint(6)
f11 varchar(10)
f12 tinyint(4)
f13 smallint(6)
f14 text
Table 2 (rows 320M)
F1 INTEGER UNSIGNED NOT NULL PRIMARY KEY
f2 INTEGER UNSIGNED NOT NULL
Table 2 is in a different database, but I am using a stored procedure that queries two tables. The relationship between the two tables is that for Table1.F1 it can be up to approx. 100 rows in table2.F1 (foreign key) that match, and the value for Table2.f2 will be returned for these mapped keys. I have index IX1 (f2 (15), f3 (10)) in table 1 and index IX2 (F1, f2) and IX3 (f2) in table 2
I execute the following queries:
SELECT g.F1
FROM DB1.Table1 g
INNER JOIN DB2.Table2 gp ON g.F1 = gp.F1
WHERE (gp.f2 = 452677825) AND
(g.f2 = 'A string value') LIMIT 0,56
(< 1s), , g.F2, , 11, 30 . , . EXPLAIN SELECT.
1, 'SIMPLE', 'g', 'ref', 'PRIMARY,IX1', 'IX1', '17', 'const', 901, 'Using where'
1, 'SIMPLE', 'gp', 'ref', 'IX3,IX2', 'IX2', '8', 'DB1.g.F1,const', 1, 'Using index'
. 2000, , . , 99,9% " ". - , , ?
,