hello all,
I am using mysql 4.1.8 and pb 7.03. I have table having 140K records. I have faced a select with where statement question. If I use select com_id,inv_cd from table1 or select com_id,inv_cd from table1 where com_id='AAA' or
select com_id,inv_cd from table1 where inv_cd like '1%'
=> it takes below 15 secords to retrieve the data
However, if i combine the where as
select com_id,inv_cd from table1 where com_id='AAA' and inv_cd like '1%'
or select com_id,inv_cd from table1 where inv_cd like '1%' and com_id='AAA'
=> it takes forever to retrieve the data
The table have three indexes: idx_1(com_id), idx_2(inv_cd) and dx_3(com_id,inv_cd) and a primary key
How does mysql handle where condition in a select statement:ie
select com_id,inv_cd from table1 where com_id='AAA' and inv_cd like '1%'
which criteria is being used first(com_id='AAA' or inv_cd like '1%'?
-- This message may have been cut off and the rest will only be shown to members. To become a member, click here --