From: brian Date: July 3 2012 4:28pm Subject: Re: alternative to slow query List-Archive: http://lists.mysql.com/mysql/227764 Message-Id: <4FF31D9A.2060807@logi.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 12-07-02 09:33 PM, yoku ts wrote: > Hello, > > add index to expression1_id and expression2_id on expression_expression. > > it doesn't use index,following, > >> WHERE >> ee2.expression1_id = $ID >> OR >> ee1.expression2_id = $ID > Thank you for your reply. The table already has indexes on these columns, however: mysql db_lexi > show index from expression_expression\G *************************** 1. row *************************** Table: expression_expression Non_unique: 0 Key_name: PRIMARY Seq_in_index: 1 Column_name: id Collation: A Cardinality: 106191 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: *************************** 2. row *************************** Table: expression_expression Non_unique: 1 Key_name: expression2_id_idx Seq_in_index: 1 Column_name: expression2_id Collation: A Cardinality: 106191 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: *************************** 3. row *************************** Table: expression_expression Non_unique: 1 Key_name: type_lien_id_idx Seq_in_index: 1 Column_name: type_lien_id Collation: A Cardinality: 43 Sub_part: NULL Packed: NULL Null: YES Index_type: BTREE Comment: *************************** 4. row *************************** Table: expression_expression Non_unique: 1 Key_name: expression1_id_idx Seq_in_index: 1 Column_name: expression1_id Collation: A Cardinality: 106191 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: 4 rows in set (0.23 sec)