In my company we use a commercial software running with mysql 5.5 (MyISAM) that often executes a query of this form:
SELECT table1.attrib1
FROM table2, table1
WHERE table2.status = 'Active'
AND table2.table1 = CONCAT( 'constant prefix', table1.attrib1 )
The output of EXAMINE
tells me that the index on table2.table1
is used, but the index on table1.attrib1
isn't used to execute the query. Instead all existing rows of table1
are accessed (full table scan). The expected result contains only a few rows.
It's a commercial software, so I can't change the query. But I could add indexes or change database parameters.
Question: What can I do to speed up this query?
SHOW GLOBAL VARIABLES LIKE 'key_buffer_size';
to find out. – RolandoMySQLDBA May 26 at 18:48SELECT data_length,index_length FROM information_schema.tables WHERE table_schema = 'database_where_table2_resides' AND table_name = 'table2';
. What is the output ? – RolandoMySQLDBA May 26 at 20:48