RE: LIKE sql optimization

2014-02-11 Thread Zhigang Zhang
Thank you very much! Zhigang -Original Message- From: Morgan Tocker [mailto:morgan.toc...@oracle.com] Sent: Wednesday, February 12, 2014 10:16 AM To: Zhigang Zhang Cc: mysql@lists.mysql.com Subject: Re: LIKE sql optimization Hi Zhigang, On Feb 11, 2014, at 8:48 PM, Zhiga

Re: LIKE sql optimization

2014-02-11 Thread Morgan Tocker
Hi Zhigang, On Feb 11, 2014, at 8:48 PM, Zhigang Zhang wrote: > I want to know the reason, in my opinion, to scan the smaller index data has > better performance than to scan the whole table data. I think I understand the question - you are asking why MySQL will not index scan, find matching

RE: LIKE sql optimization

2014-02-11 Thread Zhigang Zhang
I checked a myisam table index, the index is a copy of the whole field. Zhigang -Original Message- From: Reindl Harald [mailto:h.rei...@thelounge.net] Sent: Wednesday, February 12, 2014 10:02 AM To: mysql@lists.mysql.com Subject: Re: LIKE sql optimization because a index

Re: LIKE sql optimization

2014-02-11 Thread Mathieu Desharnais
Same reason as why composite index works only if you supply first field or fields .. example index on a,b,c if you have a query : select * from tbl where a = 'whatever' and b = 'something it will use the index .. but a query like this one : select * from tbl where b = 'something' and c = 'som

Re: LIKE sql optimization

2014-02-11 Thread louis liu
MySQL can't use index when '%' condition gives even oracle and you can try full-text search 2014-02-12 9:55 GMT+08:00 kitlenv : > *read how a index works technically* > > > On Wed, Feb 12, 2014 at 12:48 PM, Zhigang Zhang >wrote: > > > I want to know the reason, in my opinion, to scan the

Re: LIKE sql optimization

2014-02-11 Thread Reindl Harald
because a index is not just a dumb copy of the whole field and you simply can't seek in the middle of it? http://en.wikipedia.org/wiki/B-tree http://mattfleming.com/node/192 Am 12.02.2014 02:48, schrieb Zhigang Zhang: > I want to know the reason, in my opinion, to scan the smaller index data has

Re: LIKE sql optimization

2014-02-11 Thread kitlenv
*read how a index works technically* On Wed, Feb 12, 2014 at 12:48 PM, Zhigang Zhang wrote: > I want to know the reason, in my opinion, to scan the smaller index data > has > better performance than to scan the whole table data. > > > > > > zhigang > > > > _ > > From: Mathieu Desharnais [m

RE: LIKE sql optimization

2014-02-11 Thread Zhigang Zhang
I want to know the reason, in my opinion, to scan the smaller index data has better performance than to scan the whole table data. zhigang _ From: Mathieu Desharnais [mailto:mdesharn...@diffusion.cc] Sent: Wednesday, February 12, 2014 9:41 AM To: Zhigang Zhang; mysql@lists.mys

Re: LIKE sql optimization

2014-02-11 Thread Mathieu Desharnais
Sql database doesn't use index in like statement if it starts with % .. like 'abcd%' would work though... To use an index you can store your value using reverse function and index it .. then your like would use the index. 2014-02-11 20:23 GMT-05:00 Zhigang Zhang : > For example: > > > > Select

Re: LIKE sql optimization

2014-02-11 Thread Reindl Harald
Am 12.02.2014 02:23, schrieb Zhigang Zhang: > For example: > > Select * from T where col like ‘%abcd’; > > The table T is myisam table and we created a index on col. > > As we known, this like sql does not use the index created on col, it confuse > me, why? > > I think in mysiam engine, the i

LIKE sql optimization

2014-02-11 Thread Zhigang Zhang
For example: Select * from T where col like ‘%abcd’; The table T is myisam table and we created a index on col. As we known, this like sql does not use the index created on col, it confuse me, why? I think in mysiam engine, the index data is smaller, it can use index link list to op

Conditional in update

2014-02-11 Thread Larry Martell
Is there some way I can have a conditional in an update? I have this update sql (paraphrased): update LMPROC_LIMITS set LIMIT = sign(LIMIT) * 100 * floor(0.01 + (sign(LIMIT) * LIMIT * ratio/100) where SYMBOL_ID = symbolId and CLASSTYPE = LimitType and TYPE_ in ('minClusterPosition', 'maxClust

mySQL Query support/assistance...

2014-02-11 Thread Don Wieland
Hi gang, I am looking for someone that I can pay a few hours to work with me on coming up with a few needed QUERIES for a large mysql database. The queries will span across tables, so I great knowledge of JOINS will most likely be necessary. We will work using SKYPE and GoToMeeting. Please con