It's just my penchant for ordering my where clause the way I believe it will be most efficient. And I like my tables ordered to match the where clause order.
For me, at least, it makes debugging easier because I can see the flow I want. I have been known to not bother changing a query that was working perfectly fine, just to satisfy my sense of order, but since you are experimenting....... Also, if you switch manopt ON, it may make a difference, I'm not sure. The where clause order certainly will. Dennis -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Doug Hamilton Sent: Thursday, December 09, 2010 2:09 PM To: RBASE-L Mailing List Subject: [RBASE-L] - RE: LIKE vs CONTAINS on indexed column Thanks Emmitt & Dennis. CustPO is text 12, fully indexed. PK is on CusPnbr (text 15) in JobData and FK is on TxnHist - does that make any difference Dennis? How does switching the tables help? Should T1 be the PK table instead of the one being updated? Or point me to documentation if you don't have time for an explanation. Here's the whole original command: UPDATE TxnHist + SET StatCode = 'E' + FROM TxnHist T1, JobData T2 + WHERE + T1.CusPnbr = T2.CusPnbr AND + T1.StatCode = 'T' AND + T2.CUSTPO LIKE 'MP0000*' Thanks much (The '*' in the CONTAINS in my original post was a copy/paste typo), Doug Dennis McGrath wrote: > Switch the tables around and > > WHERE + > T1.CUSTPO LIKE 'MP0000*' + > AND T1.CusPnbr = T2.CusPnbr + > AND T2.StatCode = 'T' > > Dennis > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf Of Emmitt Dove > Sent: Thursday, December 09, 2010 12:33 PM > To: RBASE-L Mailing List > Subject: [RBASE-L] - RE: LIKE vs CONTAINS on indexed column > > Doug, > > You can use the (ISTAT('TOTALREADS')) function to experiment and note the > results. > > Emmitt Dove (Not Bill) > Converting Systems Architect > Evergreen Packaging, Inc. > [email protected] > (203) 214-5683 m > (203) 643-8022 o > (203) 643-8086 f > [email protected] > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf Of Doug > Hamilton > Sent: Thursday, December 09, 2010 13:08 > To: RBASE-L Mailing List > Subject: [RBASE-L] - LIKE vs CONTAINS on indexed column > > List, please refresh my memory. > I have an indexed column named CustPO. When updating, which will be faster: > WHERE CustPO LIKE 'MP000*' or > WHERE CustPO CONTAINS 'MP000*' or > something else? > MP000 is at the beginning of the text in the column. > > The full clause is: > WHERE + > T1.CusPnbr = T2.CusPnbr AND + > T1.StatCode = 'T' AND + > T2.CUSTPO LIKE 'MP0000*' > > CusPnbr are PK & FK; I assume that should be the first condition in the > WHERE clause. > StatCode can have one of 5or 6 values, so it is not indexed. > Would parenthesis help anywhere? > > Now that I've thought this through, this might be an improvement, > assuming the conditions are evaluated in the order listed, but there > were caveats to that also (I think): > WHERE + > T1.CusPnbr = T2.CusPnbr AND + > T2.CUSTPO LIKE 'MP0000*' AND + > T1.StatCode = 'T' > > I know this question comes up every year or so - I apologize for the > redundancy. > > TIA (Bill), > Doug > > > >

