sql:
  select *            
  from table_one inner join table_two   on table_two.column_one = 
table_one.column_one             
                 left join (SELECT * from table_three) table_four
                    on table_four.column_two = table_one.column_three  and 
                    table_four.column_four= table_one.column_five 
  where column_six like '%dsc%' and column_seven like '%aaa%'

  explain:

  *************************** 1. row ***************************
             id: 1
    select_type: PRIMARY
          table: table_one
           type: ALL
  possible_keys: 
            key: NULL
        key_len: NULL
            ref: NULL
           rows: 481
          Extra: Using where
  *************************** 2. row ***************************
             id: 1
    select_type: PRIMARY
          table: table_two
           type: ref
  possible_keys: idx_column_one
            key: idx_column_one
        key_len: 153
            ref: table_one.column_one
           rows: 1
          Extra: Using where
  *************************** 3. row ***************************
             id: 1
    select_type: PRIMARY
          table: <derived2>
           type: ALL
  possible_keys: NULL
            key: NULL
        key_len: NULL
            ref: NULL
           rows: 2297
          Extra:
  *************************** 4. row ***************************
             id: 2
    select_type: DERIVED
          table: table_three
           type: ALL
  possible_keys: NULL
            key: NULL
        key_len: NULL
            ref: NULL
           rows: 2250
          Extra:



  Can I optimize this sql ?
  thanks!

   

Reply via email to