RE: Curious result: Indexing numbers vs. strings

2002-01-11 Thread Roger Baklund
* Steve Rapaport Regarding integer/string conversions: select rec_no,phone_no from White where phone_no=0636941; versus select rec_no,phone_no from White where phone_no='0636941'; > Seems naive to me, since the datatype of the field is known, why > not convert the constant instead? The

RE: Curious result: Indexing numbers vs. strings

2002-01-11 Thread Sinisa Milivojevic
Anvar Hussain K.M. writes: > Hi, > Since the equality test is for a number, the phone_no field of every row of > the table > is converted into a number first and tested for the equality. This makes it > impossible > to use the character index and so forces the full table scan. > > If it were us

Re: Curious result: Indexing numbers vs. strings

2002-01-11 Thread Steve Rapaport
Dr. Frank Ullrich wrote: > Steve, > what did explain tell you in either case? Good question Dr. Ullrich. mysql> explain select rec_no,phone_no from White where phone_no=0636941; +---+--+---+--+-+--+--++ | table | type | possible_keys |

Re: Curious result: Indexing numbers vs. strings

2002-01-10 Thread Dr. Frank Ullrich
Steve, what did explain tell you in either case? Regards, Frank. Steve Rapaport wrote: > > I just found this unexpected result, those who know how > indexing works might understand it but I don't, and it's > funny: > > I have a large phone listing with over 22 million records. > The phone numb

RE: Curious result: Indexing numbers vs. strings

2002-01-10 Thread Anvar Hussain K.M.
Hi, Since the equality test is for a number, the phone_no field of every row of the table is converted into a number first and tested for the equality. This makes it impossible to use the character index and so forces the full table scan. If it were using the index then, I think, it cannot find

RE: Curious result: Indexing numbers vs. strings

2002-01-10 Thread Roger Baklund
* Steve Rapaport > I just found this unexpected result, those who know how > indexing works might understand it but I don't, and it's > funny: > > I have a large phone listing with over 22 million records. > The phone number is a string (varchar 16). > > > There's an index for the first 8 chars of