From: Paul Nowosielski Date: March 15 2011 5:15pm Subject: Optimize query help. List-Archive: http://lists.mysql.com/mysql/224648 Message-Id: <850928.21498.qm@web31101.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Dear all,=0A=0A=0AI have a query that takes a rather long time and was wond= ering if there is =0Aanyway to optimize it.=0ANormally we removing duplicat= e records by phone number. This query takes about a =0Asecond and =0A=0Ait = really slows down the process when we are importing several 1000 records a = =0Aday.=0A=0AHere is the query:=0A=0ASELECT count(id) c FROM leads=0AWHERE= (phone_home =3D '(770) 512-8990' =0AOR phone_work =3D '(770) 512-8990' =0A= OR phone_other =3D '(770) 512-8990' = =0AOR phone_mobile =3D '(770) 512-8990' =0AOR phone_fax =3D '(770) 512-89= 90') =0AAND date_entered >DATE_SUB(N= OW(),INTERVAL 45 DAY) =0AAND deleted !=3D '1';=0A=0AThis is the describe:= =0A=0ADESCRIBE SELECT count( id ) c=0AFROM leads=0AWHERE (=0Aphone_home =3D= '(770) 512-8990'=0AOR phone_work =3D '(770) 512-8990'=0AOR phone_other =3D= '(770) 512-8990'=0AOR phone_mobile =3D '(770) 512-8990'=0AOR phone_fax =3D= '(770) 512-8990')=0AAND date_entered > DATE_SUB( NOW( ) , INTERVAL 45 =0AD= AY ) =0AAND deleted !=3D '1'=0A=0A=0Aid =0Aselect_type =0Atable =0Atype =0A= possible_keys =0Akey =0Akey_len =0Aref =0Arows =0AExtra =0A=0A1 SIMPLE lead= s ALL =0Aidx_del_user,phone_home,phone_mobile,phone_work,phone_other,phone_= fax,date_entered=0A NULL NULL NULL 636433 Using where =0A=0AAny thoughts?= =0A=0AThank you,=0A=0APaul=0A=0A=0A